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

我的公众号

更多文章,请关注公众号:二进制之路

二进制之路
相关文章
相关标签/搜索