13. • Parallel Scavenge/Parallel Old
• Almost like ParNew, but it focus on the control of Throughout.
• Throughout = CPU time on user code / CPU total time.
• High throughout means more efficient.
• We can use MaxGCPauseMillis and GCTimeRatio to control this
collector.
14. • CMS (Concurrent Mark Sweep)
• Steps
• CMS initial mark
• CMS concurrent mark
• CMS remark
• CMS concurrent sweep
15. Policy of Object Allocation - Handle
Promotion
• When Survivor is too small to hold all live objects, Tenured
space will try to handle promotion.
• When minor GC is going to happen, JVM will check the
average memory amount of promoted (to tenured space)
objects.
• If it is bigger than the rest amount of tenured space. JVM will
invoke Full GC instead.
• If less, JVM will check the switch of HandlePromotionFailure.
• If switch is on, only minor GC happens.
• Else, Full GC will happen.
16. 2. Object will be allocated on Eden first.
• Where is “Eden”?
• In JVM, for new generation objects, there are 1 Eden (bigger) space
and 2 Survior (called from and to; and smaller) space.
• The default ratio between Eden and Survior is 8:1.
• Use Copying algorithm
18. 3. Big object will be allocated on
tenured space directly.
-verbose:gc
-Xms20M
-Xmx20M
-Xmn10M
-XX:+PrintGCDetails
-XX:SurvivorRatio=8
-XX:PretenureSizeThreshold=3145728
19. 4. Long-lived objects will enter
tenured space.
• JVM will give each object an age.
• After each minor GC (on new generation), lived object’s age
will increase by 1.
• Use MaxTenuringThreshold to control the behavior.
• Dynamic threshold
• if Memory(live objects with the same age) > Total Memory of
Survivor, then Objects with the same or old age will be promoted.
And it will ignore the setting of MaxTenuringThreshold.