--heapsnapshot-signal=signal
启用一个信号处理程序,当收到指定信号时,使 Node.js 进程写入堆转储。signal 必须是有效的信号名称。默认情况下为禁用。
【Enables a signal handler that causes the Node.js process to write a heap dump
when the specified signal is received. signal must be a valid signal name.
Disabled by default.】
$ node --heapsnapshot-signal=SIGUSR2 index.js &
$ ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
node 1 5.5 6.1 787252 247004 ? Ssl 16:43 0:02 node --heapsnapshot-signal=SIGUSR2 index.js
$ kill -USR2 1
$ ls
Heap.20190718.133405.15554.0.001.heapsnapshot