ataraxis
ataraxis

Reputation: 1582

heapdump of nodejs app - directly, without chrome inspect?

I would like to inspect a nodejs application because I am pretty sure we have a memory leak there. Unfortunately the app is inside a docker container which is on behind a load balancer and secured by some security rules inside EC2.

I have full access to the server on which the container is running, but I would like to get a heapdump without opening the debug ports, that's a bit beyond my wage and responsibility. What I already did is running the node using the --inspect command.

Is there a way to get a heapdump directly from within the server without connecting via chrome to it?

Unfortunately --heapsnapshot-signal seems not to work since we are using Node 8.16.1

Upvotes: 0

Views: 564

Answers (1)

stillwaiting
stillwaiting

Reputation: 474

I was able to do that successfully within the app itself with the help of v8.getHeapSnapshot(). Periodically, it checks for available free heap size using setInterval() and triggers the creation of the snapshot once an arbitrary threshold is hit (25% in my case).

Upvotes: 0

Related Questions