调用System.gc()时可以使用G1垃圾收集器

时间:2021-10-12 17:21:43

In Hotspot, when System.gc() is invoked, I can have this use the Concurrent-Mark-Sweep collector by adding the -XX:+ExplicitGCInvokesConcurrent option to the command line.

在Hotspot中,当调用System.gc()时,我可以通过在命令行中添加-XX:+ ExplicitGCInvokesConcurrent选项来使用Concurrent-Mark-Sweep收集器。

Is there anything equivalent to make the JVM use the G1 collector when System.gc() is invoked? By default, the standard parallel collector appears to be used.

在调用System.gc()时,是否有相当于使JVM使用G1收集器的东西?默认情况下,似乎使用标准并行收集器。

I'm guessing not, but I just wondered if anyone could confirm.

我猜不是,但我只是想知道是否有人可以确认。

Don't worry! I'm not planning to invoke System.gc() myself, but there are parts of the JVM (direct buffers, RMI) that rely on it being called.

别担心!我不打算自己调用System.gc(),但有些JVM(直接缓冲区,RMI)依赖于它被调用。

2 个解决方案

#1


3  

From this bug post :

从这个bug帖子:

G1 now observes ExplicitGCInvokesConcurrent

G1现在观察ExplicitGCInvokesConcurrent

there is also this link that confirm it.

还有这个链接确认它。

AFAIK there is no special command, neither the list of Oracle JVM options nor this longer list refer such command option.

AFAIK没有特殊命令,Oracle JVM选项列表和这个较长列表都没有引用这样的命令选项。

#2


0  

bool G1CollectedHeap::should_do_concurrent_full_gc(GCCause::Cause cause) {
  switch (cause) {
    case GCCause::_gc_locker:               return GCLockerInvokesConcurrent;
    case GCCause::_java_lang_system_gc:     return ExplicitGCInvokesConcurrent;
    case GCCause::_g1_humongous_allocation: return true;
    default:                                return false;

} }

And

bool ExplicitGCInvokesConcurrent = false {product}

bool ExplicitGCInvokesConcurrent = false {product}

#1


3  

From this bug post :

从这个bug帖子:

G1 now observes ExplicitGCInvokesConcurrent

G1现在观察ExplicitGCInvokesConcurrent

there is also this link that confirm it.

还有这个链接确认它。

AFAIK there is no special command, neither the list of Oracle JVM options nor this longer list refer such command option.

AFAIK没有特殊命令,Oracle JVM选项列表和这个较长列表都没有引用这样的命令选项。

#2


0  

bool G1CollectedHeap::should_do_concurrent_full_gc(GCCause::Cause cause) {
  switch (cause) {
    case GCCause::_gc_locker:               return GCLockerInvokesConcurrent;
    case GCCause::_java_lang_system_gc:     return ExplicitGCInvokesConcurrent;
    case GCCause::_g1_humongous_allocation: return true;
    default:                                return false;

} }

And

bool ExplicitGCInvokesConcurrent = false {product}

bool ExplicitGCInvokesConcurrent = false {product}