The Java program (Tomcat) continues to eat memory (RES at the top)
I run Tomcat on a 64 bit machine with 4-cpu and 32GB memory (the operating system is CentOS 6.3) My java options for starting Tomcat are - server - xms1024m - xmx1024m - XX: permsize = 512M - XX: maxpermsize = 512M
At first, res only used the top 810mb, and it kept increasing During this period, I run jmap - j-d64 - histo PID to check the JAVA memory heap. I think GC works normally because the heap peak is 510mb and the post GC peak is about 200MB However, when the top res reaches 1.1g, the CPU utilization will exceed 100% and Tomcat will hang
When the CPU utilization is 100%, use jstack PID to view the dump. The thread named "VM thread" occupies almost 100% of the CPU I use Google search, which is a JVM GC thread So my question is: when GC works normally, why does res continue to grow? How can I solve this problem? thank you.
Solution
If the garbage collection thread rotates at 100%, it may be that it is trying to perform garbage collection, but no objects can be collected, so you are in the garbage collection death spiral. It has been trying to run but can't release any memory
This may be because there is a memory leak in your program, or because you do not give VM enough memory to handle the number of objects loaded during normal use Sounds like you have enough space to increase the heap size This may only extend the time before you reach the death spiral, or it may put you into operation You need to test for a long time to make sure you're not just delaying the inevitable