@@ -434,7 +434,7 @@ Prior to Node.js 8.0.0, the underlying memory for `Buffer` instances
434
434
created in this way is * not initialized* . The contents of a newly created
435
435
` Buffer ` are unknown and * may contain sensitive data* . Use
436
436
[ ` Buffer.alloc(size) ` ] [ `Buffer.alloc()` ] instead to initialize a ` Buffer `
437
- to zeroes.
437
+ with zeroes.
438
438
439
439
``` js
440
440
const buf = new Buffer (10 );
@@ -550,7 +550,7 @@ thrown. A zero-length `Buffer` will be created if `size` is 0.
550
550
The underlying memory for ` Buffer ` instances created in this way is * not
551
551
initialized* . The contents of the newly created ` Buffer ` are unknown and
552
552
* may contain sensitive data* . Use [ ` Buffer.alloc() ` ] instead to initialize
553
- ` Buffer ` instances to zeroes.
553
+ ` Buffer ` instances with zeroes.
554
554
555
555
``` js
556
556
const buf = Buffer .allocUnsafe (10 );
@@ -593,20 +593,20 @@ thrown. A zero-length `Buffer` will be created if `size` is 0.
593
593
594
594
The underlying memory for ` Buffer ` instances created in this way is * not
595
595
initialized* . The contents of the newly created ` Buffer ` are unknown and
596
- * may contain sensitive data* . Use [ ` buf.fill(0) ` ] [ `buf.fill()` ] to initialize such
597
- ` Buffer ` instances to zeroes.
596
+ * may contain sensitive data* . Use [ ` buf.fill(0) ` ] [ `buf.fill()` ] to initialize
597
+ such ` Buffer ` instances with zeroes.
598
598
599
599
When using [ ` Buffer.allocUnsafe() ` ] to allocate new ` Buffer ` instances,
600
- allocations under 4KB are, by default, sliced from a single pre-allocated
601
- ` Buffer ` . This allows applications to avoid the garbage collection overhead of
602
- creating many individually allocated ` Buffer ` instances. This approach improves
603
- both performance and memory usage by eliminating the need to track and cleanup as
604
- many ` Persistent ` objects.
600
+ allocations under 4KB are sliced from a single pre-allocated ` Buffer ` . This
601
+ allows applications to avoid the garbage collection overhead of creating many
602
+ individually allocated ` Buffer ` instances. This approach improves both
603
+ performance and memory usage by eliminating the need to track and clean up as
604
+ many persistent objects.
605
605
606
606
However, in the case where a developer may need to retain a small chunk of
607
607
memory from a pool for an indeterminate amount of time, it may be appropriate
608
- to create an un-pooled ` Buffer ` instance using ` Buffer.allocUnsafeSlow() ` then
609
- copy out the relevant bits.
608
+ to create an un-pooled ` Buffer ` instance using ` Buffer.allocUnsafeSlow() ` and
609
+ then copying out the relevant bits.
610
610
611
611
``` js
612
612
// Need to keep around a few small chunks of memory
@@ -625,8 +625,8 @@ socket.on('readable', () => {
625
625
});
626
626
```
627
627
628
- Use of ` Buffer.allocUnsafeSlow() ` should be used only as a last resort * after*
629
- a developer has observed undue memory retention in their applications.
628
+ ` Buffer.allocUnsafeSlow() ` should be used only as a last resort after a
629
+ developer has observed undue memory retention in their applications.
630
630
631
631
A ` TypeError ` will be thrown if ` size ` is not a number.
632
632
@@ -2464,7 +2464,8 @@ thrown. A zero-length `Buffer` will be created if `size` is 0.
2464
2464
2465
2465
The underlying memory for ` SlowBuffer ` instances is * not initialized* . The
2466
2466
contents of a newly created ` SlowBuffer ` are unknown and may contain sensitive
2467
- data. Use [ ` buf.fill(0) ` ] [ `buf.fill()` ] to initialize a ` SlowBuffer ` to zeroes.
2467
+ data. Use [ ` buf.fill(0) ` ] [ `buf.fill()` ] to initialize a ` SlowBuffer ` with
2468
+ zeroes.
2468
2469
2469
2470
``` js
2470
2471
const { SlowBuffer } = require (' buffer' );
0 commit comments