Does java garbage collection log entry “Full GC (System)” mean some class called System.gc()?

前端 未结 2 2121
栀梦
栀梦 2020-12-08 20:22

What does \"Full GC (System)\" entry in the garbage collection logs mean? That some class called System.gc() ?

My garbage collection logs has two different entry typ

2条回答
  •  庸人自扰
    2020-12-08 21:07

    From the source for OpenJDK I would say it is

    const bool is_system_gc = gc_cause == GCCause::_java_lang_system_gc;
    
    // This is useful for debugging but don't change the output the
    // the customer sees.
    const char* gc_cause_str = "Full GC";
    if (is_system_gc && PrintGCDetails) {
      gc_cause_str = "Full GC (System)";
    }
    

    I created a custom version of the Runtime class to record the thread name and stack trace to a file whenever Runtime.getRuntime().gc() was called. (System.gc() calls this) I found it useful in tracking down and removing such callers.

    One place this happens is in sun.misc.GC class. The RMI will ask this class to ensure a GC has been performing in the last N seconds. If there has been no GC it triggers a full GC.

    This only shows as a problem if you reduce the number of minor GCs. Ironicly it can mean you get more full GCs. ;)

    I don't use RMI (except perhaps JConsole) So I have it set to a week. (Think the default is an hour)

    -Dsun.rmi.dgc.server.gcInterval=604800000
    -Dsun.rmi.dgc.client.gcInterval=604800000
    

提交回复
热议问题