Is Concurrent Mark Sweep (CMS) a stop the world event?

后端 未结 3 1715
礼貌的吻别
礼貌的吻别 2020-12-15 08:18

I see many unloading of classes and my entire system will hang during that period of time..

[Unloading class sun.reflect.GeneratedMethodAccessor117]
[Unloadi         


        
3条回答
  •  不知归路
    2020-12-15 08:58

    CMS is not an "event". It is a garbage collector. CMS does have a couple of phases where everything is stopped, but under normal circumstances these are very short (a few milliseconds). In general, if you get a long pause it means that the CMS is not able to keep up with the rate of garbage generation (within the constraints that have been set), and that the JVM has had to perform a full GC using the "mark-sweep" collector ... which is stop the world.

    Depending on your JVM, it may be that the permgen only gets collected when a full GC occurs, and that classes are only collected / unloaded when the permgen is GC'ed.

    But you can't infer that the class unloading causes the long pauses. In fact, it is more likely the other way around if your GC stats say that the permgen is not filling up.

    It is also possible that your logging of class unloading is causing the "stop the world" problem: see http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6637203


    Observations:

    • If you have thousands of messages about unloading dynamically created classes, then I would take a look at the architecture of your system. Are you over-using proxy classes?

    • With Java 8, permgen goes away and is replaced with metaspace. Upgrading may ease your problems.

提交回复
热议问题