Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a flag to collect heap dump before crashing on out of memory #32756

Closed
puzpuzpuz opened this issue Apr 10, 2020 · 5 comments
Closed

Add a flag to collect heap dump before crashing on out of memory #32756

puzpuzpuz opened this issue Apr 10, 2020 · 5 comments

Comments

@puzpuzpuz
Copy link
Member

Is your feature request related to a problem? Please describe.

Existing ways to collect a (full) heap dump are not production-friendly. The proposed flag can be enabled for production application in order to help with post-mortem memory leak diagnostics.

Describe the solution you'd like

Add a new new flag (say, --heapsnaphot-on-outofmemory) that would enable collection of a heap dump before terminating node process in the out of memory scenario.

Additional context. Such option (-XX:+HeapDumpOnOutOfMemoryError) is available in JVM (e.g. in OpenJDK) for a long time and many developers use it.

Describe alternatives you've considered

I can see the following alternatives:

  • --heapsnapshot-signal=signal - this option assumes a signal that is sent to node process externally. Thus, it's not possible to trigger it on out-of-memory.
  • heapdump user-land module - quite similar to sending a signal, yet it's triggered programmatically inside the node application.
  • node-oom-heapdump user-land module - seems to implement the proposed feature, but I believe that such feature should belong to the core in order to be well-tested.
  • --heap-prof - this option enables V8 sampling heap profiler which reports are not quite the same as a full heap dump (yet, they're certainly valuable for users).
@vdeturckheim
Copy link
Member

That would be a great feature. Is there already a hook in V8 to run actions when process runs out of memory?

@puzpuzpuz
Copy link
Member Author

That would be a great feature. Is there already a hook in V8 to run actions when process runs out of memory?

By looking at node-oom-heapdump's documentation, I can say that it's possible to use isolate.SetOOMErrorHandler for the purpose (there may be better solutions, but I'm not sure).

@bnoordhuis
Copy link
Member

Duplicate of #27552. That issue also discusses the problems with that feature.

@puzpuzpuz
Copy link
Member Author

puzpuzpuz commented Apr 10, 2020

Duplicate of #27552. That issue also discusses the problems with that feature.

@bnoordhuis Thanks for this reference. I searched for existing issues, but probably missed this one. Going to read it now.

@puzpuzpuz
Copy link
Member Author

Closing this one as a duplicate. Going to upvote the CLI option in #27552.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants