Jvm cms collector, jvmcms collection
CMS (Concurrent Mark Sweep) has the shortest pause recovery and is suitable for maintaining the response time requirements.
- Initial tag Initial mark: mark the objects that can be associated with GC Roots. Stop-mark.
- Mark Concurrent mark: GC Roots tracing for Concurrent business threads.
- Remark: remark the tag record of the object that changes when the user program is running at the same time. Stop-mark.
- Concurrent cleanup Concurrent sweep: Clear useless objects.
The initial tag and re-tag take a short time.
Disadvantages:
- In the concurrency phase, cpu resources are used, user programs are slowed down, and throughput is reduced. CMS is enabled by default (CPU + 3)/4 threads for execution.
- Floating Gorbage cannot be processed. The garbage generated by the user program in the concurrent cleaning stage becomes Floating garbage and cannot be processed for the same time. In order to reserve the user program to use memory, the CMS needs to collect data at a certain percentage in the old age.-XX: CMSInitiatingOccupancyFractionSet the ratio of CMS in the old age.
- The CMS Based on the tag clearing algorithm will produce a lot of space fragments in the old age, which is not conducive to the use of large objects.-UseCMSCompactAtFullCollection (true by default)To fragment and compress when CMS is to be collected. This setting will cause a pause. You can also set-XX: CMSFullGCsBeforeCompactionTo set the number of times the CMS is executed, that is, the number of times the CMS is collected, the number of times the fragment is executed.