Garbage Collection Topic (1)--Full GC

1. What is Full GC?

GC is performed on the new generation, old generation, and permanent generation, that is, Full GC. You can use -XX:ScanengeBeforeFullGC to disable GC for the young generation during Full GC.

 

2. Full GC trigger condition

①System.gc(); can be disabled with -XX:_DisableExplicitGC

②Insufficient space in the old generation (transfer of new generation objects, creation of large objects, large arrays) After Full GC, OutOfMemoryError: Java heap space is still insufficient.

③ The permanent generation space is full (there are many loading classes, reflection classes, and calling methods), and OutOfMemoryError: PermGen space is still insufficient after Full GC.

④Promotion failed during CMS GC (From/To cannot be placed in Young GC, neither can the old generation) and concurret mode failure (CMS GC has objects to be placed in the old generation at the same time, but there is not enough space)

⑤ The size of the object to be moved to the old generation when counting Young GC is larger than the remaining space of the old generation

⑥ RMI will perform Full GC once an hour, you can use -Java -Dsun.rmi.dgc.client.gcInterval=3600000 to set the interval (you can use -XX:_DisableExplicitGC to prohibit RMI from calling System.gc())

 

In a word, the cause of Full GC is that a lot of new objects are created , which are not actively released in time, resulting in insufficient Eden memory. Therefore, it is necessary to continuously migrate objects to the old age, which causes the space of the old age to be full, so Full GC must be performed.

 

3. How to prevent Full GC:

①If the cache hit rate is not high, do not use the cache

②In the case where the cache is not applicable, the memory is too small, or there is a problem with setting parameters, which will cause Full GC.

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326016041&siteId=291194637