There was a recent heap memory overflow for a Java service, then zombie, and a dump file was generated with the Jmap command before restarting the service for later analysis.
command to generate dump file:
Jmap-dump:format=b,file=20170307.dump 16048
After file is the custom filename, and the last number is the PID of the process.
use JVISUALVM to analyze dump files:
JVISUALVM is the JDK's own Java profiling tool, and in the JDK's Bin directory, the filename is called Jvisualvm.exe.
JVISUALVM can monitor the local, remote Java processes, real-time view of the process CPU, heap, thread and other parameters, the Java process to generate dump files, and the dump file analysis.
Like me this dump from the server file can also be thrown directly to the JVISUALVM to analyze.
Use: Direct double hit open jvisualvm.exe, click File-> loaded, in the file type that column select heap, select the dump file to analyze, open.
After loading the profile, class, and so on to the right of the interface can see the heap information generated at the time of the dump file:
As you can see, an instance of the heap in the dump file, the total size of about 300M, can be calculated by dividing the instance size of the first row by a percentage, and the JVM's default Cenozoic size is much smaller than the maximum heap memory set in the JVM, i.e. The dump file does not record the state when the instance size reaches the maximum heap memory.
to verify, I simulated the heap memory overflow locally and used JVISUALVM to monitor
My local set of maximum heap memory is about 800M, inside the code is to a list of crazy add data, until the heap of memory, the monitoring content is this:
Analysis: The red box out part of the heap memory overflow occurs when the situation, the size of the heap used (the blue portion) did not grow particularly noticeable, but the size of the requested heap (the yellow portion) soared from the default of 400 trillion, up to 800M, and then the memory overflowed, while the heap size of the application still did not grow much.
So, the list of instances in the dump file is actually a reflection of the heap used, and the heap memory used is not up to the maximum of the preset heap memory, but the maximum heap memory is exceeded in the process of requesting heap memory, and then the memory overflows.
Finally, JVISUALVM is very useful.