--zero-fill-buffers 命令行选项


【The --zero-fill-buffers command-line option】

可以使用 --zero-fill-buffers 命令行选项启动 Node.js,以便默认情况下所有新分配的 Buffer 实例在创建时都会填充为零。如果不使用该选项,使用 Buffer.allocUnsafe()Buffer.allocUnsafeSlow()new SlowBuffer(size) 创建的缓冲区不会被填充为零。使用此标志可能会对性能产生可测量的负面影响。只有在需要确保新分配的 Buffer 实例不包含可能敏感的旧数据时,才使用 --zero-fill-buffers 选项。

【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>