1.
windows & Linux:
修改运行脚本的javaw 到java,并且添加参数-XX:+HeapDumpOnCtrlBreak。
运行程序后,按ctrl+break, 就可以得到heapdump文件。
-Djava.awt.headless=true -XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=c:\heapdump
2.
solaris:
首先在运行的脚本中添加参数-XX:+HeapDumpOnCtrlBreak。
利用ps -ef | grep java 找到运行程序的进程号。
输入命令kill -3 <pid>,就可以得到heapdump文件。
或者: kill -QUIT <pid>
-Djava.awt.headless=true -XX:+HeapDumpOnOutOfMemoryError
3. AIX
(1) choose one cluster member, set the following before
this server start:
在was启动前设置下面环境变量(可以加在启动脚本中)
export IBM_HEAPDUMP=true
export IBM_HEAP_DUMP=true
export IBM_HEAPDUMP_OUTOFMEMORY=true
export IBM_HEAPDUMPDIR=<directory
path>
export IBM_JAVADUMP_OUTOFMEMORY=true
(2)please use set command to make sure you do not have
DISABLE_JAVADUMP parameter
then start this cluster member.
用set命令检查参数设置,确保没有设置DISABLE_JAVADUMP,然后启动server
(3)when you find free memory < 50% when no
heavy access, please run kill -3
<pid>
执行kill -3
<pid>命令可以生成javacore文件和heapdump文件(pid为was
java进程的id号,可以用ps -ef|grep java 查到),可以多执行几次.
e.g. 例如
Types of OutOfMemoryError in Java
1) Java.lang.OutOfMemoryError: Java heap space
2) Java.lang.OutOfMemoryError: PermGen space
http://javarevisited.blogspot.com/2011/09/javalangoutofmemoryerror-permgen-space.html
How to solve Java.lang.OutOfMemoryError: PermGen space
export JVM_ARGS="-Xmx1024m -XX:MaxPermSize=256m"
How to solve java.lang.OutOfMemoryError: Java heap space
export JVM_ARGS="-Xms1024m -Xmx1024m"
# Set juli LogManager config file if it is present and an override has not been issued
#JAVA_OPTS="$JAVA_OPTS -server -Xms1024M -Xmx1024M -Xss128m -XX:PermSize=128M -XX:MaxPermSize=512M"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port="9004" -Dcom.sun.management.jmxremote.authenticate=fales -Dcom.sun.management.jmxremote.ssl=fales -Djava.awt.headless=true"
#JAVA_OPTS="$JAVA_OPTS -server -Xms1024M -Xmx1024M"
JAVA_OPTS="$JAVA_OPTS -server -Xms1024M -Xmx1024M -Xmn128M -XX:MaxNewSize=256m -XX:MaxPermSize=256m -XX:SurvivorRatio=65536 -XX:MaxTenuringThreshold=0 -XX:+PrintHeapAtGC -Xloggc:gc.log -XX:+DisableExplicitGC -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction=0 -XX:+CMSClassUnloadingEnabled -XX:+PerfBypassFileSystemCheck -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/user/tomcat6/apache-tomcat-6.0.35/bin"