-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 support for -XX:+HeapDumpOnOutOfMemoryError #7012
Conversation
Pushed a couple of commits:
This PR is ready for review now. @christianhaeubl can you have a look? @zakkak can you make this PR not a draft? I'm not able to do it, nor can I add reviewers...etc. |
By the way, the style errors reported are unrelated to the code changes in this PR. |
I can't do it either, It says:
|
unblocked the PR :) |
Thanks @fniephaus. Having had a day to think about this, there's one doubt I have lingering, which is what to do if the heap dump file already exists. As it stands, any existing heap dumps would be overwritten, but I'm unsure if more than one OOME can be fired. In HotSpot you can have code that catches and ignores and so you'll get more OOMEs fired, but in SVM, an OOME does not bubble up all the way to the application. The main thread simply halts and the program finishes. In any case, assuming multiple OOMEs can be fired, what HotSpot does is append a number to the file, but in SVM, the code that fires the OOME can't create new file names. So, you would have to pre-allocate a number of files in advance in case they're needed, which is a bit clunky. E.g. how many would you pre-allocate? Side note: I've not been able to trigger HotSpot to generate multiple heap dump files on OOME, even after catching the OOME and continue trying to allocate objects. Multiple OOMEs are fired but only one dump file. |
Can someone add the redhat-interest label? @zakkak @roberttoyonaga can you do that? |
Why can't the code that fires the OOME create new file names? If it's because the code is not allowed to allocate managed memory, I'm sure @christianhaeubl can show you how to do this with native/unmanaged memory. Or am I missing something?
Me neither, but maybe possible if you're running multiple threads and they all see OOMEs? Regardless, I'd argue we should stay as close to the HotSpot impl as possible. |
@fniephaus Actually, I misread the HotSpot code. Appending a number to the heap dump file is only done when multiple heap dumps are produced in the case of VM errors other than OOME, e.g.
The What is relevant to this PR, which I have only realised when I tried OOMEs with multiple threads, is that if multiple threads reach the same point, only one heap dump is produced:
I need to add the necessary protection so that only one heap dump is produced. I'll add that next. |
e61f461
to
9a8c441
Compare
Added support for only generating one heap dump on OOME. Also fixed the conflict. |
Thanks for the PR, I did a bunch of changes and fixes on top (see #7088). Feel free to review and comment the changes that I pushed. It might take a few more days until this PR gets merged. |
Closes #4641.
Implements support for
-XX:+HeapDumpOnOutOfMemoryError
flag.I've made some small changes to the
HeapDumpOperation
to be able to use it for this use case. The key thing is that all code in the operation has to be allocation free, which meant tweaking the error reporting method to not allocate. After discussing with @christianhaeubl, a new set ofopen
andcreate
methods have been added that take aCCharPointer
. On startup, if-XX:+HeapDumpOnOutOfMemoryError
is passed, the filename is pre-calculated and stored temporarily in case it's needed. Then, when OOME hits, theCCharPointer
is used to create the file descriptor and pass it to the native VM operation.To use
-XX:+HeapDumpOnOutOfMemoryError
, native image has to be built with--enable-monitoring=heapdump
.I will push the documentation updates shortly.