一、前言
Linux服务器环境下,tomcat服务器堆内存溢出异常,并打印dump错误文件内容(由于提前配置 -XX:HeapDumpPath=/home/app/tomcat7/logs/dump 堆内存异常输出路径),这是急需分析当前堆内存到底是存的什么对象内容,从而分析和该对象相关输出代码。
二、操作示例步骤
1)jps打印进程pid
[root@iZuf6gyurl0fqb87hirq23Z ~]# jps@b@22415 Jps@b@21113 Bootstrap
2)jstack命令
[root@iZuf6gyurl0fqb87hirq23Z ~]# jstack 21113@b@@b@"http-bio-9980-exec-414" daemon prio=10 tid=0x00007fb3b0478000 nid=0x548c runnable [0x00007fb004e2d000]@b@ java.lang.Thread.State: RUNNABLE@b@ at java.net.SocketInputStream.socketRead0(Native Method)@b@ at java.net.SocketInputStream.read(SocketInputStream.java:152)@b@ at java.net.SocketInputStream.read(SocketInputStream.java:122)@b@ at org.apache.http.impl.io.AbstractSessionInputBuffer.read(AbstractSessionInputBuffer.java:204)@b@ at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:182)@b@ at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:204)@b@ at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:155)@b@ at org.apache.http.util.EntityUtils.toByteArray(EntityUtils.java:118)@b@ at com.xwood.demo.util.HttpClientUtil.proxyWriteGetByte(HttpClientUtil.java:188)@b@ at com.xwood.gw.processor.StreamDirectoryProxyJumpProcessor.serviceProxyJump(StreamDirectoryProxyJumpProcessor.java:334)@b@ at com.xwood.gw.processor.StreamDirectoryProxyJumpProcessor.doProcess(StreamDirectoryProxyJumpProcessor.java:381)@b@ at com.xwood.gw.processor.core.AbstractProcessor.process(AbstractProcessor.java:14)@b@ at com.xwood.gw.processor.core.ProcessorChain.process(ProcessorChain.java:22)@b@ at com.xwood.gw.filter.GateWayProcessorFilter.doFilter(GateWayProcessorFilter.java:59)@b@ at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)@b@ at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)@b@ at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)@b@ at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)@b@ at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)@b@ at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)@b@ at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)@b@ at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)@b@ at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)@b@ at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)@b@ at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)@b@ at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)@b@ at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)@b@ - locked <0x00000000c4461360> (a org.apache.tomcat.util.net.SocketWrapper)@b@ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)@b@ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)@b@ at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)@b@ at java.lang.Thread.run(Thread.java:745)@b@@b@"http-bio-9980-exec-413" daemon prio=10 tid=0x00007fb3b1d4c000 nid=0x548b runnable [0x00007fb006c2e000]@b@ java.lang.Thread.State: RUNNABLE@b@ at java.net.SocketInputStream.socketRead0(Native Method)@b@ at java.net.SocketInputStream.read(SocketInputStream.java:152)@b@ at java.net.SocketInputStream.read(SocketInputStream.java:122)@b@ at org.apache.http.impl.io.AbstractSessionInputBuffer.read(AbstractSessionInputBuffer.java:204)@b@ at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:182)@b@ at org.apache.h^C
另外更多vm分析命令操作示例