Java ParNew gc 会停止世界吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4406809/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 17:06:16  来源:igfitidea点击:

ParNew gc will stop the world?

javagarbage-collection

提问by user537555

I see GC output like below:

我看到 GC 输出如下:

2010-12-10T16:00:44.942+0800: 1443.562: [GC 1443.562: [ParNew: 201856K->17318K(201856K), 0.0352970 secs] 2113334K->1949037K(4416748K) icms_dc=0 , 0.0354310 secs] [Times: user=0.12 sys=0.00, real=0.04 secs]
2010-12-10T16:00:46.207+0800: 1444.827: [GC 1444.827: [ParNew: 196774K->22400K(201856K), 0.0119290 secs] 2128493K->1954446K(4416748K) icms_dc=0 , 0.0120560 secs] [Times: user=0.13 sys=0.00, real=0.02 secs]
2010-12-10T16:00:47.562+0800: 1446.182: [GC 1446.182: [ParNew: 201856K->22400K(201856K), 0.0714350 secs] 2133902K->1982695K(4416748K) icms_dc=0 , 0.0715720 secs] [Times: user=0.23 sys=0.01, real=0.07 secs]
2010-12-10T16:00:48.545+0800: 1447.165: [GC 1447.165: [ParNew: 201856K->22400K(201856K), 0.1457230 secs] 2162151K->2008418K(4416748K) icms_dc=0 , 0.1458710 secs] [Times: user=0.71 sys=0.05, real=0.15 secs]

I want to know if ParNew GC will stop all threads. Thanks.

我想知道 ParNew GC 是否会停止所有线程。谢谢。

采纳答案by JoseK

Jon Masamitsu's blogsays so quite clearly

Jon Masamitsu 的博客说得很清楚

"ParNew" is a stop-the-world, copying collector which uses multiple GC threads.

“ParNew”是一个停止世界的复制收集器,它使用多个 GC 线程。

In the example you've shown, the timings are reasonably quick though

在您展示的示例中,虽然时间相当快

回答by dogbane

Yes, ParNew is a "stop-the-world" collection which collects the young generation. Since the young generation is normally small in size, the collection should be very quick and shouldn't impact your application too much.

是的,ParNew 是一个“stop-the-world”系列,收集年轻一代。由于年轻代通常很小,因此收集应该非常快,并且不会对您的应用程序产生太大影响。

回答by eckes

Yes, it is stop the world. In your example you will see the pause time inside the square brackets. It is usually the same as the real time. The user? time is the actual CPU time spent in GCing. It can be much larger than the real time when parallelity is used. In your case it looks like 4 GC threads.

是的,它是停止世界。在您的示例中,您将看到方括号内的暂停时间。它通常与实时相同。用户?time 是在 GC 中花费的实际 CPU 时间。当使用并行性时,它可能比实时大得多。在您的情况下,它看起来像 4 个 GC 线程。

回答by Rostam

Yes it stops, the world, though depending on your heap size and application, looks like you can use a larger newGen size. You are doing minor GC every minute. Larger newGen size does not necessarily mean that you will have a longer minor GC time. Though the benefit is that you will not promote objects that will soon die to the Old Gen. When the time comes for a full gc, you will have less objects to remove, and less downtime.

是的,它停止了,虽然取决于您的堆大小和应用程序,但看起来您可以使用更大的 newGen 大小。您每分钟都在进行次要 GC。较大的 newGen 大小并不一定意味着您将有更长的次要 GC 时间。尽管这样做的好处是您不会将很快就会死掉的对象提升到 Old Gen。当需要执行完整 gc 时,您将需要删除的对象更少,停机时间也更少。