--zero-fill-buffers 命令行选项
如果没有该选项,则使用 Buffer.allocUnsafe()
、Buffer.allocUnsafeSlow()
和 new SlowBuffer(size)
创建的缓冲区不会填零。
使用此标志会对性能产生可衡量的负面影响。
仅在必要时使用 --zero-fill-buffers
选项以强制新分配的 Buffer
实例不能包含可能敏感的旧数据。
$ node --zero-fill-buffers
> Buffer.allocUnsafe(5);
<Buffer 00 00 00 00 00>
Node.js can be started using the --zero-fill-buffers
command line option to
cause all newly-allocated Buffer
instances to be zero-filled upon creation by
default. Without the option, buffers created with Buffer.allocUnsafe()
,
Buffer.allocUnsafeSlow()
, and new SlowBuffer(size)
are not zero-filled.
Use of this flag can have a measurable negative impact on performance. Use the
--zero-fill-buffers
option only when necessary to enforce that newly allocated
Buffer
instances cannot contain old data that is potentially sensitive.
$ node --zero-fill-buffers
> Buffer.allocUnsafe(5);
<Buffer 00 00 00 00 00>