<commit_before>## buffer-dispose

If this is so dangerous why should you use it? Because it can drastically
increase throughput by relieving pressure from the garbage collector.

This is what's left of an attempt to allow users to manually free memory
attached to a Buffer instance. It was too precarious to do in core, so now I'm
making my efforts available here.

Use like so:

```javascript
var dispose = require('buffer-dispose');

// this can only be used on non-slices, will throw otherwise
var SlowBuffer = require('buffer').SlowBuffer;
var buf = new SlowBuffer(5);
console.log(buf);
dispose(buf);
console.log(buf);

// output:
// <Buffer 00 00 00 00 00>
// <Buffer >
```

It's mainly meant to be used for incoming data. Now that the `SlabAllocator` has
been removed no incoming I/O is directly part of a slice. Though this is
**only** the case when the stream is in **flowing mode**.

Take the following example:

```javascript
var dispose = require('buffer-dispose');

function onData(chunk) {
  // do some quick operations on the chunk
  dispose(chunk);
}

function onConnection(socket) {
  socket.on('data', onData);
}

require('net').createServer(onConnection).listen(8000);
```

Each incoming chunk in the above case is uniquely allocated and can be disposed
when the operation is complete. Though you **must** make sure all requests
against the data are complete. This means you must be aware of any asynchronous
events. In the following example a buffer is queued to be written to disk, but
then memory is released before the asynchronous event is able to complete.

```javascript
var dispose = require('buffer-dispose');
var fs = require('fs');
var buf = require('buffer').SlowBuffer(10);
buf.fill('a');

fs.writeFile('test.txt', buf, function() { });

// disposing here means nothing will be written to disk
dispose(buf);
```

To install this from a non-globally installed build of master, use the
following:

```
/path/to/build/node `which npm` --nodedir=/path/to/build install buffer-dispose
```<commit_msg>Add comment how to build module<commit_after>## buffer-dispose

If this is so dangerous why should you use it? Because it can drastically
increase throughput by relieving pressure from the garbage collector.

This is what's left of an attempt to allow users to manually free memory
attached to a Buffer instance. It was too precarious to do in core, so now I'm
making my efforts available here.

Use like so:

```javascript
var dispose = require('buffer-dispose');

// this can only be used on non-slices, will throw otherwise
var SlowBuffer = require('buffer').SlowBuffer;
var buf = new SlowBuffer(5);
console.log(buf);
dispose(buf);
console.log(buf);

// output:
// <Buffer 00 00 00 00 00>
// <Buffer >
```

It's mainly meant to be used for incoming data. Now that the `SlabAllocator` has
been removed no incoming I/O is directly part of a slice. Though this is
**only** the case when the stream is in **flowing mode**.

Take the following example:

```javascript
var dispose = require('buffer-dispose');

function onData(chunk) {
  // do some quick operations on the chunk
  dispose(chunk);
}

function onConnection(socket) {
  socket.on('data', onData);
}

require('net').createServer(onConnection).listen(8000);
```

Each incoming chunk in the above case is uniquely allocated and can be disposed
when the operation is complete. Though you **must** make sure all requests
against the data are complete. This means you must be aware of any asynchronous
events. In the following example a buffer is queued to be written to disk, but
then memory is released before the asynchronous event is able to complete.

```javascript
var dispose = require('buffer-dispose');
var fs = require('fs');
var buf = require('buffer').SlowBuffer(10);
buf.fill('a');

fs.writeFile('test.txt', buf, function() { });

// disposing here means nothing will be written to disk
dispose(buf);
```

To install this from a non-globally installed build of master, use the
following:

```
/path/to/build/node `which npm` --nodedir=/path/to/build install buffer-dispose
```

To build the library I do the following:

```
/path/to/build/node `which npm` --nodedir=/path/to/build install njsutil bindings
/path/to/build/node `which node-gyp` rebuild --nodedir=/path/to/build
```

Probably a better way to do this, but eh. It works for now. Submit a ticket if
you have something better.
{'fraction_non_alphanumeric': 0.10273972602739725, 'fraction_numerical': 0.007762557077625571, 'mean_word_length': 4.47625, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3558294', 'n_tokens_mistral': 1317, 'n_tokens_neox': 1215, 'n_words': 578}