JDK6 and 7 server-side (-server) default new garbage collector is: PS scavenge, the default garbage collector for the old age: PS MarkSweep
At present, the project uses JDK7,TOMCAT7, often appear memory heap usage 200s continuously exceeds heap total memory 80%, triggers the alarm.
Due to the recent update of the project for JDK and Tomcat upgrades from 6 to 7, the previous use of TOMCAT6 was not reported as a result of a change in Tomcat behavior pattern.
<listener classname= "Org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
In Tomcat6, it invokes the System.GC () method every one hours, and executes the full GC manually, so that useless objects in the old age are cleaned up every hour;
In Tomcat7, things have changed, it is not every long.max_value s to perform a System.GC (), this time is too long;
Back to the actual project, the old age continues to increase, the average day will trigger one or two times full GC, in this project, the old memory usage for a long time, and the new generation of memory usage with the business frequency changes, sometimes quickly full, triggering young GC; sometimes it grows slowly, If the sum of young memory + old memory exceeds 80% of the heap memory capacity, the alarm will be reported.
Overall, the long-term memory consumption in the old period is high, the growth is faster, is the main cause of this problem.
Let's start by understanding some of the terminology of garbage collection algorithms:
PS Scavenge: The New generation garbage collector, using the replication algorithm (memory is divided into eden,s1,s2), parallel multi-threaded collector, it is concerned about the throughput of the system, efficient use of the CPU, as soon as possible to complete the task, not too concerned about thread pause time. It has an adaptive policy that causes the virtual machine parameter configuration-xx:survivorratio parameter to have no practical meaning (the size of the S1,S2 will vary), of course, which is also a reference control
Mark-Clear MarkSweep: The memory is divided into many blocks, the object is marked with no reference, the object is collected uniformly after the mark is cleared, the space is not contiguous after clearing, the allocation of large objects may not find enough space to trigger a garbage collection
(Deep understanding of Java Virtual Machine second map)
Java Memory Alarm garbage collection