Simple OutOfMemoryError profiling with VisualVM
Today I used Java heap profiling to investigate a problem with Scala futures.
Start your Java program with the following options. I used a maximum heap size of 32 megabytes to speed up the error. When an OutOfMemoryError occurs, a heap profile file will be dumped.
-Xmx32m -XX:+HeapDumpOnOutOfMemoryError
Start VisualVM. On Mac OS 10.8 it is located at the following location:
/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/jvisualvm
Choose File > Load and open the heap profile (hprof) file.
You’ll be presented with a summary of class memory usage.
Investigate!