How to detect the cause of OutofMemoryError?

后端 未结 5 1872
慢半拍i
慢半拍i 2021-02-08 11:44

I have a complaint that a server application of mine is crashing on high load.
It is a web app running in Tomcat 5.
I see the thread dumps and I see that th

5条回答
  •  悲哀的现实
    2021-02-08 12:15

    You should start the JVM with the -XX:+HeapDumpOnOutOfMemoryError flag. This will produce a heap dump when the OutOfMemoryError is generated.

    Then, as @Steve said, you can use a tool like MAT to analyze the dump and see which objects are allocated, and who is keeping references to them. This usually will give you some insight on why your JVM is exhausting its memory.

提交回复
热议问题