Java memory analysis summary, java memory Summary
1. built-in jconsole tool.
(1) If it is started from the command line, make JDK on the PATH and run jconsole.
(2) If you start from the GUI shell, find the JDK installation path, open the bin folder, and double-clickJconsole.
(3) When the analysis tool pops up (depending on the running Java version and the number of running Java programs), a dialog box may appear asking you to enter a process URL to connect,
It is also possible to list many different local Java processes (sometimes including the JConsole process itself) for connection.
Reference http://jiajun.iteye.com/blog/810150
2. built-in jmap Tool
Jmap is a tool that can output all objects in the memory. It can even output heap in the VM in binary format as text. Use jmap-histo pid. If you use SHELL jmap-histo pid>. log can save it to the text (which can also be used in windows). After a period of time, you can use the text comparison tool to compare which objects are collected by GC.
(1) DOS query port and PID in windows: TaskList/svc
(2) Use the netstat-ano command to list the PID corresponding to all ports
3. mat
A. Generate a dump file
A process corresponds to a. hprof file,
(1) set jvm parameters:-XX: + HeapDumpOnOutOfMemoryError. The java_pid7888.hprof file is located in the current project directory;
(2) Using jmap-dump: format = B, file = HeapDump. bin <pid>
(3) generated through jconsole
Choose Mbean> com. sun. management> HotSpotDiagnos> Operations> dumpHeap.
In the p0 parameter, enter the path for saving the dmp file, for example, f:/my. hprof. The extension name of the file must be hprof.
Click dumpHeap to generate the dump file.
B. Install mat and open the. hprof file for analysis.
JAVA memory Analysis
In other words, "3" and "5" should be the same as the variable name, the basic type.
Java memory Analysis
Very simple. "Hello World" has been created for temporary storage during construction.
String temp = "Hello World ";
String str = new String (temp)