1
votes

I have been analyzing java.lang.OutOfMemoryError: Java heap space for our service and trying to dig the heap dumps via Eclipse MAT tool.

Our service is running with 8G heap and the generated heap dump is of size only 500 MB.

Here are the JVM CommandLine flags: -XX:-DoEscapeAnalysis -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/tmp -XX:InitialHeapSize=8589934592 -XX:MaxGCPauseMillis=10 -XX:MaxHeapSize=8589934592 -XX:NewSize=4294967296 -XX:OnOutOfMemoryError=/bin/kill -9 %p -XX:+PrintClassHistogram -XX:-PrintCommandLineFlags -XX:+PrintGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -XX:SurvivorRatio=8 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseG1GC

Heap dump size: -rw------- 1 taxadm amazon 557201181 Sep 16 15:10 java_pid4026.hprof

Is this correct heap dump ? Because it is highly unlikely that our service is trying to allocate 7.5 GB array ?

Thanks for your help

2

2 Answers

0
votes

That sounds way too small, are you sure your out of memory is not due to PermGen Space OOM? Generated dump files can be small when you manually generate them much later after the OOM happened but that is not the case with you.

0
votes

Just in case someone ends up here looking for:

java.lang.OutOfMemoryError: Java heap space

Like I did: using XX:+HeapDumpOnOutOfMemoryError is important. I had code that accidentally created infinite loop and using jmap -heap after error showed nothing wrong, no leaks and actually low heap usage. On the other hand heapdump automatically done on OOM was large and clearly showed (in MAT) what went wrong.