Java之CMS GC Causes

Allocation Failure

Allocation Failure happens when there isn't enough free space to create new objects in Young generation. Allocation failures triggers Young GC.html

On Linux, the JVM can trigger a GC if the kernel notifies there isn't much memory left via mem_notify.java

  • 產生緣由:新生代沒有足夠的空間分配對象。
  • 觸發GC類型:Young GC。

GCLocker Initiated GC

The GC locker prevents GC from occurring when JNI code is in a critical region. If GC is needed while a thread is in a critical region, then it will allow them to complete, i.e. call the corresponding release function. Other threads will not be permitted to enter a critical region. Once all threads are out of critical regions a GC event will be triggered.oracle

  • 產生緣由:若是線程執行在JNI臨界區時,恰好須要進行GC,此時GC locker將會阻止GC的發生,同時阻止其餘線程進入JNI臨界區,直到最後一個線程退出臨界區時觸發一次GC。
  • 觸發GC類型:GCLocker Initiated GC。

Promotion Failure

Promotion Failure happens when there is no continuous memory space to promote larger object, even though total free memory is large enough. This is problem is called as heap fragmentation. Promotion Failure typically triggers Full GC.app

  • 產生緣由:老年代沒有足夠的連續空間分配給晉升的對象(即便總可用內存足夠大)。
  • 觸發GC類型:Full GC。
  • 解決方法:增長堆內存,特別是新生代內存,儘量讓對象在新生代被回收掉。減小對象的建立,縮短對象的生命週期。

Concurrent Mode Failure

The CMS collector uses one or more garbage collector threads that run simultaneously with the application threads with the goal of completing the collection of the tenured generation before it becomes full. In normal operation, the CMS collector does most of its tracing and sweeping work with the application threads still running, so only brief pauses are seen by the application threads. However, if the CMS collector is unable to finish reclaiming the unreachable objects before the tenured generation fills up, or if an allocation cannot be satisfied with the available free space blocks in the tenured generation, then the application is paused and the collection is completed with all the application threads stopped. The inability to complete a collection concurrently is referred to as concurrent mode failure and indicates the need to adjust the CMS collector parameters. Concurrent mode failure typically triggers Full GC.jvm

  • 產生緣由:CMS GC運行期間,老年代預留的空間不足以分配給新的對象。
  • 觸發GC類型:Full GC。
  • 解決方法:適當調低-XX:CMSInitiatingOccupancyFraction,或者增長老年代內存。

關於GCLocker Initiated GC

shipilev.net/jvm-anatomy…ide

bugs.openjdk.java.net/browse/JDK-…ui

www.zhihu.com/question/61…atom

docs.oracle.com/javase/8/do…spa

docs.oracle.com/javase/8/do….net

我的公衆號

更多文章,請關注公衆號:二進制之路

二進制之路
相關文章
相關標籤/搜索