Take the 2-minute tour ×

I have a java application which is getting an OutOfMemoryError, for heap space. I've enabled -XX:HeapDumpOnOutOfMemoryError, and have the resultant hprof file.

The dump, however, shows that there is plenty of space left in the heap, permgen, etc. I believe this may be cause of single request for large amount of memory (e.g., a 1 GB array), which fails and thus doesn't show up in the dump.

Basically I'd like to see the stack of the thread that caused the OOM at the point the OOM is thrown.

Is that possible from the hprof dump?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

It is not in the dump because it is in the OutOfMemoryError. If you manage to catch and print the stack trace of that error, it will tell where it happens.

share|improve this answer
I guess that's it! A bit unfortunate given that it's the most important single piece of information, and in many cases (e.g., a large array request due to a bug which far exceeds available memory) it's the only thing you care about. If you weren't set up to log it, or the logs cannot be obtained, you are SOL, I guess. –  BeeOnRope Jul 29 '11 at 22:26
I do agree, especially when you use the XX:HeapDumpOnOutOfMemoryError it could easily include the trace! –  Simone Gianni Jul 30 '11 at 4:19
add comment

Your Answer


