分析
- 测试环境应用运行发生了异常,OutOfMemoryError:Java heap space 估计是内存溢出不够了。但是却又有特别的异常信息.
- 出现OOM问题一般主要是申请资源不够,申请资源太多,资源耗尽
- 常见原因:内存太小了,但应用确实需要大量内存;对象被申请却没有释放,导致内存不断泄漏;资源被频繁申请,资源耗尽
- 命令:jmap -heap 10765 查看内存情况 (服务进程:PID 10765)
- 命令:jmap -histo:live 10765 | more 找出最耗内存的对象
日志文件
tomcat.catlina.out文件如下:
# java.lang.OutOfMemoryError: Java heap space
# -XX:OnOutOfMemoryError="sh oom.sh %p /data/project/lml-web/tomcat/bin"
# Executing /bin/sh -c "sh oom.sh 8892 /data/project/lml-web/tomcat/bin"...
内存溢出.....
20180412_112653
name=/data/project/lml-web/tomcat/bin&ip=10.132.171.145&time=2018-04-12 11:26:53&pid=8892
Attaching to process ID 8892, please wait...
Attaching to process ID 8892, please wait...
Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the process
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 15 0 15 0 0 34 0 --:--:-- --:--:-- --:--:-- 0
OK
Debugger attached successfully.
Server compiler detected.
JVM version is 24.65-b04
sun.jvm.hotspot.debugger.UnalignedAddressException: 11
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$1.checkAlignment(LinuxDebuggerLocal.java:181)
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.readCInteger(LinuxDebuggerLocal.java:480)
at sun.jvm.hotspot.debugger.DebuggerBase.readCompOopAddressValue(DebuggerBase.java:459)
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.readCompOopHandle(LinuxDebuggerLocal.java:442)
at sun.jvm.hotspot.debugger.linux.LinuxAddress.getCompOopHandleAt(LinuxAddress.java:125)
at sun.jvm.hotspot.oops.Oop.getKlassForOopHandle(Oop.java:231)
at sun.jvm.hotspot.oops.ObjectHeap.newOop(ObjectHeap.java:380)
at sun.jvm.hotspot.runtime.JavaThread.getThreadObj(JavaThread.java:331)
at sun.jvm.hotspot.runtime.JavaThread.getCurrentParkBlocker(JavaThread.java:383)
at sun.jvm.hotspot.runtime.DeadlockDetector.print(DeadlockDetector.java:82)
at sun.jvm.hotspot.runtime.DeadlockDetector.print(DeadlockDetector.java:39)
at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:52)
at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45)
at sun.jvm.hotspot.tools.JStack.run(JStack.java:60)
at sun.jvm.hotspot.tools.Tool.start(Tool.java:221)
at sun.jvm.hotspot.tools.JStack.main(JStack.java:86)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.tools.jstack.JStack.runJStackTool(JStack.java:136)
at sun.tools.jstack.JStack.main(JStack.java:102)
sun.jvm.hotspot.debugger.UnmappedAddressException: b42a0508
at sun.jvm.hotspot.debugger.PageCache.checkPage(PageCache.java:208)
at sun.jvm.hotspot.debugger.PageCache.getData(PageCache.java:63)
at sun.jvm.hotspot.debugger.DebuggerBase.readBytes(DebuggerBase.java:217)
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.readCInteger(LinuxDebuggerLocal.java:482)
at sun.jvm.hotspot.debugger.DebuggerBase.readCompOopAddressValue(DebuggerBase.java:459)
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.readCompOopHandle(LinuxDebuggerLocal.java:442)
at sun.jvm.hotspot.debugger.linux.LinuxAddress.getCompOopHandleAt(LinuxAddress.java:125)
at sun.jvm.hotspot.oops.Oop.getKlassForOopHandle(Oop.java:231)
at sun.jvm.hotspot.oops.ObjectHeap.newOop(ObjectHeap.java:380)
at sun.jvm.hotspot.runtime.JavaThread.getThreadObj(JavaThread.java:331)
at sun.jvm.hotspot.runtime.JavaThread.getCurrentParkBlocker(JavaThread.java:383)
at sun.jvm.hotspot.runtime.DeadlockDetector.print(DeadlockDetector.java:82)
at sun.jvm.hotspot.runtime.DeadlockDetector.print(DeadlockDetector.java:39)
at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:52)
at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45)
at sun.jvm.hotspot.tools.JStack.run(JStack.java:60)
at sun.jvm.hotspot.tools.Tool.start(Tool.java:221)
at sun.jvm.hotspot.tools.JStack.main(JStack.java:86)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.tools.jstack.JStack.runJStackTool(JStack.java:136)
at sun.tools.jstack.JStack.main(JStack.java:102)
sun.jvm.hotspot.debugger.UnalignedAddressException: 29
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$1.checkAlignment(LinuxDebuggerLocal.java:181)
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.readCInteger(LinuxDebuggerLocal.java:480)
at sun.jvm.hotspot.debugger.DebuggerBase.readCompOopAddressValue(DebuggerBase.java:459)
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.readCompOopHandle(LinuxDebuggerLocal.java:442)
at sun.jvm.hotspot.debugger.linux.LinuxAddress.getCompOopHandleAt(LinuxAddress.java:125)
at sun.jvm.hotspot.oops.Oop.getKlassForOopHandle(Oop.java:231)
at sun.jvm.hotspot.oops.ObjectHeap.newOop(ObjectHeap.java:356)
at sun.jvm.hotspot.oops.NarrowOopField.getValue(NarrowOopField.java:44)
at sun.jvm.hotspot.oops.OopUtilities.threadOopGetParkBlocker(OopUtilities.java:294)
at sun.jvm.hotspot.runtime.JavaThread.getCurrentParkBlocker(JavaThread.java:385)
at sun.jvm.hotspot.runtime.DeadlockDetector.print(DeadlockDetector.java:82)
at sun.jvm.hotspot.runtime.DeadlockDetector.print(DeadlockDetector.java:39)
at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:52)
at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45)
at sun.jvm.hotspot.tools.JStack.run(JStack.java:60)
at sun.jvm.hotspot.tools.Tool.start(Tool.java:221)
at sun.jvm.hotspot.tools.JStack.main(JStack.java:86)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.tools.jstack.JStack.runJStackTool(JStack.java:136)
at sun.tools.jstack.JStack.main(JStack.java:102)