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


¥The --zero-fill-buffers command-line option

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

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