diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 9e6eabb77caa1e..9e0433b00067c7 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -881,7 +881,7 @@ _may contain sensitive data_. Use [`buf.fill(0)`][`buf.fill()`] to initialize such `Buffer` instances with zeroes. When using [`Buffer.allocUnsafe()`][] to allocate new `Buffer` instances, -allocations less than `Buffer.poolSize >>> 1` (4KiB when default poolSize is used) are sliced +allocations less than `Buffer.poolSize >>> 1` (32KiB when default poolSize is used) are sliced from a single pre-allocated `Buffer`. This allows applications to avoid the garbage collection overhead of creating many individually allocated `Buffer` instances. This approach improves both performance and memory usage by @@ -1513,9 +1513,13 @@ console.log(Buffer.isEncoding('')); -* Type: {integer} **Default:** `8192` +* Type: {integer} **Default:** `65536` This is the size (in bytes) of pre-allocated internal `Buffer` instances used for pooling. This value may be modified. diff --git a/lib/buffer.js b/lib/buffer.js index 5c983b5a240108..4377b53d865f65 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -169,7 +169,7 @@ const constants = ObjectDefineProperties({}, { }, }); -Buffer.poolSize = 8 * 1024; +Buffer.poolSize = 64 * 1024; let poolSize, poolOffset, allocPool, allocBuffer; function createPool() {