Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
MemoryAnalyzer
Contents
About
The Eclipse Memory Analyzer is a fast and feature-rich heap analyzer that helps you find big chunks of memory and identify who is keeping these objects alive.
Getting Started
How to Get a Heap Dump?
The Memory Analyzer works with HPROF binary formatted heap dumps. These are the available options to acquire one:
Via Java VM parameters
- -XX:+HeapDumpOnOutOfMemoryError writes heap dump on OutOfMemoryError (recommended)
- -XX:+HeapDumpOnCtrlBreak writes heap dump together with thread dump on CTRL+BREAK
- -agentlib:hprof=heap=dump,format=b combines the above two settings (old way; not recommended as the VM frequently dies after CTRL+BREAK with strange errors)
Via tools:
- Sun JMap: jmap.exe -dump:format=b,file=HeapDump.hprof <pid>
- Sun JConsole: Launch jconsole.exe and invoke operation dumpHeap() on HotSpotDiagnostic MBean
- SAP JVMMon: Launch jvmmon.exe and call menu for dumping the heap
Heap dump will be written to the working directory.
Vendor / Release | VM Parameter | VM Tools | |||
---|---|---|---|---|---|
On OoM | On Ctrl+Break | Agent | JMap | JConsole | |
Sun, HP | |||||
1.4.2_12 | Yes | Yes | Yes | ||
1.5.0_07 | Yes | Yes | Yes (Only Solaris and Linux) | ||
1.6.0_00 | Yes | Yes | Yes | Yes | |
SAP | |||||
1.5.0_07 | Yes | Yes | Yes | Yes (Only Solaris and Linux) |
What if the Heap Dump is NOT Written on OutOfMemoryError?
Heap dumps are not written on OutOfMemoryError for the following reasons:
- Application creates and throws OutOfMemoryError on its own
- Another resource like threads per process is exhausted
- C heap is exhausted
As for the C heap, the best way to see that you won't get a heap dump is if it happens in C code (eArray.cpp in the example below):
# An unexpected error has been detected by SAP Java Virtual Machine: # java.lang.OutOfMemoryError: requested 2048000 bytes for eArray.cpp:80: GrET*. Out of swap space or heap resource limit exceeded (check with limits or ulimit)? # Internal Error (\\...\hotspot\src\share\vm\memory\allocation.inline.hpp, 26), pid=6000, tid=468
C heap problems may arise for different reasons, e.g. out of swap space situations, process limits exhaustion or just address space limitations, e.g. heavy fragmentation or just the depletion of it on machines with limited address space like 32 bit machines. The hs_err-file will help you with more information on this type of error. Java heap dumps wouldn't be of any help, anyways.
Also please note that a heap dump is written only on the first OutOfMemoryError. If the application chooses to catch it and continues to run, the next OutOfMemoryError will never cause a heap dump to be written!