Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nodejs USR2 signal kills process using heapdump

Using heapdump, I'm trying to take some heap snapshots of node

as per https://blog.risingstack.com/finding-a-memory-leak-in-node-js/

Sending USR2 to a node process that has required heapdump should trigger heapdump to save a heap snapshot to the working directory.

On my local server (running on a mac) this works great. On an AWS ubuntu server, USR2 kills the process. I've also tried SIGUSR2.

Does anyone know why "sudo kill -USR2 " would be killing the process instead of triggering a heap snapshot?

like image 860
wallacer Avatar asked Sep 02 '25 09:09

wallacer


1 Answers

This could happen because of two reasons:

  • In some distros the kill code is USR2 and in others it's SIGUSR2. You need to run kill -l to check which one your distro supports.

  • require('heapdump') is not executed in the current worker. So if you are use node cluster module then you need to require heapdump in the current worker i.e.

if (worker.isMaster) { /* master stuff */ } else { require('heapdump') }

like image 136
neebz Avatar answered Sep 05 '25 01:09

neebz