Reputation: 31
I'm recently developing a rest service with tomcat. I set JAVA_OPTS = -Xmx1648m -Xmn1648 -server and make sure they already take effect. The docker is running with memory limit set to 4g.
The observation is that the memory usage by the tomcat process keeps growing, eventually to 4g. Then, the memory cost stays between 99% ~ 100% for time randomly between several minutes to hours. Then, the tomcat process crashes without any error like jvm heap oom.
I used jmap to dump the heap when the memory consumption observed by docker stats is around 3.5g. The dump file size is below 400m. Using mat to analyze the dump file shows most memory fraction actually could be garbage collected. I also manually run jcmd pid GC.run which largely reduced the memory usage (from 2g to 1.4g).
My inspection is that tomcat never reached the limit set by jvm, otherwise, there should be error log about jvm heap oom. Then, the memory should be consumed by jvm or other threads within tomcat. But I couldn't find a way to fix this problem. Please help!
Upvotes: 2
Views: 2064
Reputation: 1132
When Xmx is set to 1648 ie 1.4G then JVM will not use more than that. If there is memory allocation issue then it could lead to OOM. When you say "memory cost stays between 99% ~ 100%" Do you mean RAM memory? In that case, what is your RAM Size? What is your task load?. Are you doing frequent I/O Operation?
Upvotes: 0