3

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?

Kara
  • 6,115
  • 16
  • 50
  • 57
BeeOnRope
  • 60,350
  • 16
  • 207
  • 386

1 Answers1

4

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.

Simone Gianni
  • 11,426
  • 40
  • 49
  • 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 04:19