3

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?

wallacer
  • 12,855
  • 3
  • 27
  • 45

1 Answers1

4

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') }

neebz
  • 11,465
  • 7
  • 47
  • 64