@@ -808,7 +808,7 @@ A `TypeError` will be thrown if `size` is not a number.
808
808
The ` Buffer ` module pre-allocates an internal ` Buffer ` instance of
809
809
size [ ` Buffer.poolSize ` ] [ ] that is used as a pool for the fast allocation of new
810
810
` Buffer ` instances created using [ ` Buffer.allocUnsafe() ` ] [ ] , [ ` Buffer.from(array) ` ] [ ] ,
811
- and [ ` Buffer.concat() ` ] [ ] only when ` size ` is less than
811
+ [ ` Buffer.from(string) ` ] [ ] , and [ ` Buffer.concat() ` ] [ ] only when ` size ` is less than
812
812
` Buffer.poolSize >>> 1 ` (floor of [ ` Buffer.poolSize ` ] [ ] divided by two).
813
813
814
814
Use of this pre-allocated internal memory pool is a key difference between
@@ -846,11 +846,11 @@ _may contain sensitive data_. Use [`buf.fill(0)`][`buf.fill()`] to initialize
846
846
such ` Buffer ` instances with zeroes.
847
847
848
848
When using [ ` Buffer.allocUnsafe() ` ] [ ] to allocate new ` Buffer ` instances,
849
- allocations under 4 KiB are sliced from a single pre-allocated ` Buffer ` . This
850
- allows applications to avoid the garbage collection overhead of creating many
851
- individually allocated ` Buffer ` instances. This approach improves both
852
- performance and memory usage by eliminating the need to track and clean up as
853
- many individual ` ArrayBuffer ` objects.
849
+ allocations less than ` Buffer.poolSize >>> 1 ` (4KiB when default poolSize is used) are sliced
850
+ from a single pre-allocated ` Buffer ` . This allows applications to avoid the
851
+ garbage collection overhead of creating many individually allocated ` Buffer `
852
+ instances. This approach improves both performance and memory usage by
853
+ eliminating the need to track and clean up as many individual ` ArrayBuffer ` objects.
854
854
855
855
However, in the case where a developer may need to retain a small chunk of
856
856
memory from a pool for an indeterminate amount of time, it may be appropriate
@@ -1388,6 +1388,9 @@ console.log(buf1.toString('latin1'));
1388
1388
A ` TypeError ` will be thrown if ` string ` is not a string or another type
1389
1389
appropriate for ` Buffer.from() ` variants.
1390
1390
1391
+ [ ` Buffer.from(string) ` ] [ ] may also use the internal ` Buffer ` pool like
1392
+ [ ` Buffer.allocUnsafe() ` ] [ ] does.
1393
+
1391
1394
### Static method: ` Buffer.isBuffer(obj) `
1392
1395
1393
1396
<!-- YAML
@@ -5442,10 +5445,10 @@ to one of these new APIs._
5442
5445
uninitialized, the allocated segment of memory might contain old data that is
5443
5446
potentially sensitive.
5444
5447
5445
- ` Buffer ` instances returned by [ ` Buffer.allocUnsafe() ` ] [ ] and
5446
- [ ` Buffer.from(array) ` ] [ ] _ may_ be allocated off a shared internal memory pool
5447
- if ` size ` is less than or equal to half [ ` Buffer.poolSize ` ] [ ] . Instances
5448
- returned by [ ` Buffer.allocUnsafeSlow() ` ] [ ] _ never_ use the shared internal
5448
+ ` Buffer ` instances returned by [ ` Buffer.allocUnsafe() ` ] [ ] , [ ` Buffer.from(string) ` ] [ ] ,
5449
+ [ ` Buffer.concat() ` ] [ ] and [ ` Buffer. from(array)` ] [ ] _ may_ be allocated off a shared
5450
+ internal memory pool if ` size ` is less than or equal to half [ ` Buffer.poolSize ` ] [ ] .
5451
+ Instances returned by [ ` Buffer.allocUnsafeSlow() ` ] [ ] _ never_ use the shared internal
5449
5452
memory pool.
5450
5453
5451
5454
### The ` --zero-fill-buffers ` command-line option
0 commit comments