Concurrent Mark Sweep (CMS) 是一项停止世界活动吗?

我看到许多类卸载,我的整个系统在那段时间里都会挂起..

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

[Unloading class sun.reflect.GeneratedMethodAccessor117]
[Unloading class sun.reflect.GeneratedConstructorAccessor1896]
[Unloading class sun.reflect.GeneratedSerializationConstructorAccessor485]
[Unloading class sun.reflect.GeneratedSerializationConstructorAccessor579]
.... // about 1700 of them

同时我没有看到烫发空间出现峰值,所以这似乎不是 GC 事件.

at the same time I do not see a spike in perm space, so it doesn't seems to be a GC event.

我想知道以下内容

Concurrent Mark Sweep 收集是停止世界事件吗?

IS Concurrent Mark Sweep collection a stop the world event?

烫发空间未满时也会出现这种情况吗?

Does it happen even when the perm space is not full?

推荐答案

CMS是GC的一种,分阶段

CMS is a type of GC and is divided into phases

你可以看到两个阶段 - 初始标记和备注是停止世界事件.

As you can see two phases - Initial mark and Remark are stop the world events.

来源:在 查看世代 GC 和 CMS 部分.

Does it happen even when the perm space is not full?

AFAIK 为此你应该有 CMSClassUnloadingEnabledUseConcMarkSweepGC.当永久区域达到其阈值时,将触发 FGC.

AFAIK for this you should have CMSClassUnloadingEnabled with UseConcMarkSweepGC. And FGC will be triggered when permgen area reaches it's threshold.

虽然并发扫描(短语(4))不是 STW 事件,如果 permgen 区域被填满(并且 GC 仍在处理 permgen 区域),它可能会导致停止所有进程线程并且只有 GC 线程运行直到所有需要的内存被回收.

Also though Concurrent Sweep(phrase (4)) is not STW event if permgen area get filled up(and GC is still processing permgen area) it may led to stopping all process threads and only GC thread running till all required memory is reclaimed.

相关文章