Tomcat heapdump configuration file

The system sometimes encounter OutOfMemoryError, Java heap overflow. We need to find the cause OutOfMemoryError reasons. There are two cases:

1, memory leaks, the object is dead and can not be automatically recovered by the garbage collector;

2, memory overflow, memory objects must also be alive, indicating that insufficient Java heap space allocation, check the settings heap size (-Xmx and -Xms), check the code whether there is an object life cycle is too long, the state holding time is too long.

 

Think before the leak occurred, to take heap dump analysis, by jvm parameters -XX: + HeapDumpOnOutOfMemoryError (XX: + HeapDumpOnCtrlBreak do not know why not start tomcat) allows the JVM in the event of memory overflow Dump is a snapshot of the current memory dump .

Of course, it can also be used by jmap produce dump file. View through the windows task manager of process pid tomcat, linux view the process pid with ps command and then use jmap command (Java5: jmap -heap: format = b <pid>; Java6: jmap -dump: format = b, file = HeapDump .bin <pid>)

 

Set in the tomcat jvm parameters

linux system

1. Open the file /tomcat_home/bin/catalina.sh 

2.加上:JAVA_OPTS="$JAVA_OPTS -server -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=D:\heapdump"

FIG position follows:

NOTE: wherein no -XX: HeapDumpPath time, dump the files in the / tomcat_home / bin directory

Windows System

1. Open the file /tomcat_home/bin/catalina.bat

2.加上:set JAVA_OPTS=%JAVA_OPTS% -server -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=D:\heapdump

FIG position follows:

 

Analysis dump out of the memory snapshot file

 

You can use analysis tools for analysis, such as:

 

Eclipse's MAT

Download: http: //www.eclipse.org/mat/downloads.php

Documentation: http: //www.vogella.com/articles/EclipseMemoryAnalyser/article.html#example_project

 

Note: parsing may cause excessive HeapDump Eclipse throw OutOfMemory error. Then you need to manually adjust the size of the cache Eclipse, reference may be given by the official website of treatment ( original connection )

 

Alternatively, edit the MemoryAnalyzer.ini to contain:

-vmargs
-Xmx2g
-XX:-UseGCOverheadLimit

Eclipse plug-in version of the open version of the RPC friends can try MAT ( my 232m of the dump file to open it, do not have to use the 64bit machine it? ): RPC version MAT Download  .

 

JProfile

 

And so on;

Transfer: http://jiangsha.iteye.com/blog/1576355

Guess you like

Origin blog.csdn.net/qq_34730511/article/details/80568103