分析

  1. 测试环境应用运行发生了异常,OutOfMemoryError:Java heap space 估计是内存溢出不够了。但是却又有特别的异常信息.
  2. 出现OOM问题一般主要是申请资源不够,申请资源太多,资源耗尽
  3. 常见原因:内存太小了,但应用确实需要大量内存;对象被申请却没有释放,导致内存不断泄漏;资源被频繁申请,资源耗尽
  4. 命令:jmap -heap 10765 查看内存情况 (服务进程:PID 10765)
  5. 命令:jmap -histo:live 10765 | more 找出最耗内存的对象

日志文件

tomcat.catlina.out文件如下:

  1. # java.lang.OutOfMemoryError: Java heap space
  2. # -XX:OnOutOfMemoryError="sh oom.sh %p /data/project/lml-web/tomcat/bin"
  3. # Executing /bin/sh -c "sh oom.sh 8892 /data/project/lml-web/tomcat/bin"...
  4. 内存溢出.....
  5. 20180412_112653
  6. name=/data/project/lml-web/tomcat/bin&ip=10.132.171.145&time=2018-04-12 11:26:53&pid=8892
  7. Attaching to process ID 8892, please wait...
  8. Attaching to process ID 8892, please wait...
  9. Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the process
  10. % Total % Received % Xferd Average Speed Time Time Time Current
  11. Dload Upload Total Spent Left Speed
  12. 0 15 0 15 0 0 34 0 --:--:-- --:--:-- --:--:-- 0
  13. OK
  14. Debugger attached successfully.
  15. Server compiler detected.
  16. JVM version is 24.65-b04
  17. sun.jvm.hotspot.debugger.UnalignedAddressException: 11
  18. at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$1.checkAlignment(LinuxDebuggerLocal.java:181)
  19. at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.readCInteger(LinuxDebuggerLocal.java:480)
  20. at sun.jvm.hotspot.debugger.DebuggerBase.readCompOopAddressValue(DebuggerBase.java:459)
  21. at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.readCompOopHandle(LinuxDebuggerLocal.java:442)
  22. at sun.jvm.hotspot.debugger.linux.LinuxAddress.getCompOopHandleAt(LinuxAddress.java:125)
  23. at sun.jvm.hotspot.oops.Oop.getKlassForOopHandle(Oop.java:231)
  24. at sun.jvm.hotspot.oops.ObjectHeap.newOop(ObjectHeap.java:380)
  25. at sun.jvm.hotspot.runtime.JavaThread.getThreadObj(JavaThread.java:331)
  26. at sun.jvm.hotspot.runtime.JavaThread.getCurrentParkBlocker(JavaThread.java:383)
  27. at sun.jvm.hotspot.runtime.DeadlockDetector.print(DeadlockDetector.java:82)
  28. at sun.jvm.hotspot.runtime.DeadlockDetector.print(DeadlockDetector.java:39)
  29. at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:52)
  30. at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45)
  31. at sun.jvm.hotspot.tools.JStack.run(JStack.java:60)
  32. at sun.jvm.hotspot.tools.Tool.start(Tool.java:221)
  33. at sun.jvm.hotspot.tools.JStack.main(JStack.java:86)
  34. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  35. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  36. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  37. at java.lang.reflect.Method.invoke(Method.java:606)
  38. at sun.tools.jstack.JStack.runJStackTool(JStack.java:136)
  39. at sun.tools.jstack.JStack.main(JStack.java:102)
  40. sun.jvm.hotspot.debugger.UnmappedAddressException: b42a0508
  41. at sun.jvm.hotspot.debugger.PageCache.checkPage(PageCache.java:208)
  42. at sun.jvm.hotspot.debugger.PageCache.getData(PageCache.java:63)
  43. at sun.jvm.hotspot.debugger.DebuggerBase.readBytes(DebuggerBase.java:217)
  44. at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.readCInteger(LinuxDebuggerLocal.java:482)
  45. at sun.jvm.hotspot.debugger.DebuggerBase.readCompOopAddressValue(DebuggerBase.java:459)
  46. at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.readCompOopHandle(LinuxDebuggerLocal.java:442)
  47. at sun.jvm.hotspot.debugger.linux.LinuxAddress.getCompOopHandleAt(LinuxAddress.java:125)
  48. at sun.jvm.hotspot.oops.Oop.getKlassForOopHandle(Oop.java:231)
  49. at sun.jvm.hotspot.oops.ObjectHeap.newOop(ObjectHeap.java:380)
  50. at sun.jvm.hotspot.runtime.JavaThread.getThreadObj(JavaThread.java:331)
  51. at sun.jvm.hotspot.runtime.JavaThread.getCurrentParkBlocker(JavaThread.java:383)
  52. at sun.jvm.hotspot.runtime.DeadlockDetector.print(DeadlockDetector.java:82)
  53. at sun.jvm.hotspot.runtime.DeadlockDetector.print(DeadlockDetector.java:39)
  54. at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:52)
  55. at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45)
  56. at sun.jvm.hotspot.tools.JStack.run(JStack.java:60)
  57. at sun.jvm.hotspot.tools.Tool.start(Tool.java:221)
  58. at sun.jvm.hotspot.tools.JStack.main(JStack.java:86)
  59. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  60. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  61. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  62. at java.lang.reflect.Method.invoke(Method.java:606)
  63. at sun.tools.jstack.JStack.runJStackTool(JStack.java:136)
  64. at sun.tools.jstack.JStack.main(JStack.java:102)
  65. sun.jvm.hotspot.debugger.UnalignedAddressException: 29
  66. at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$1.checkAlignment(LinuxDebuggerLocal.java:181)
  67. at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.readCInteger(LinuxDebuggerLocal.java:480)
  68. at sun.jvm.hotspot.debugger.DebuggerBase.readCompOopAddressValue(DebuggerBase.java:459)
  69. at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.readCompOopHandle(LinuxDebuggerLocal.java:442)
  70. at sun.jvm.hotspot.debugger.linux.LinuxAddress.getCompOopHandleAt(LinuxAddress.java:125)
  71. at sun.jvm.hotspot.oops.Oop.getKlassForOopHandle(Oop.java:231)
  72. at sun.jvm.hotspot.oops.ObjectHeap.newOop(ObjectHeap.java:356)
  73. at sun.jvm.hotspot.oops.NarrowOopField.getValue(NarrowOopField.java:44)
  74. at sun.jvm.hotspot.oops.OopUtilities.threadOopGetParkBlocker(OopUtilities.java:294)
  75. at sun.jvm.hotspot.runtime.JavaThread.getCurrentParkBlocker(JavaThread.java:385)
  76. at sun.jvm.hotspot.runtime.DeadlockDetector.print(DeadlockDetector.java:82)
  77. at sun.jvm.hotspot.runtime.DeadlockDetector.print(DeadlockDetector.java:39)
  78. at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:52)
  79. at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45)
  80. at sun.jvm.hotspot.tools.JStack.run(JStack.java:60)
  81. at sun.jvm.hotspot.tools.Tool.start(Tool.java:221)
  82. at sun.jvm.hotspot.tools.JStack.main(JStack.java:86)
  83. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  84. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  85. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  86. at java.lang.reflect.Method.invoke(Method.java:606)
  87. at sun.tools.jstack.JStack.runJStackTool(JStack.java:136)
  88. at sun.tools.jstack.JStack.main(JStack.java:102)