java PS MarkSweep 是哪个垃圾收集器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39929758/
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
PS MarkSweep is which garbage collector
提问by gpengtao
My jdk version is :
我的 jdk 版本是:
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
this is my test code :
这是我的测试代码:
List<GarbageCollectorMXBean> beans = ManagementFactory.getGarbageCollectorMXBeans();
for (GarbageCollectorMXBean bean : beans) {
System.out.println(bean.getName());
}
result is :
结果是:
PS Scavenge
PS MarkSweep
I know PS Scavenge is "Parallel Scavenge" of young generation garbage collector, "PS MarkSweep" is which, is it "Parallel Old"?
我知道 PS Scavenge 是年轻代垃圾收集器的“Parallel Scavenge”,“PS MarkSweep”是哪个,是“Parallel Old”吗?
回答by Mike
For the benefit of anyone else finding this question, there is a great overview here:
为了其他发现这个问题的人的利益,这里有一个很好的概述:
http://www.fasterj.com/articles/oraclecollectors1.shtml
http://www.fasterj.com/articles/oraclecollectors1.shtml
To quote the relevant parts for this question:
引用这个问题的相关部分:
Young generation collectors
Copy (enabled with -XX:+UseSerialGC)
the serial copy collector, uses one thread to copy surviving objects from Eden to Survivor spaces and between Survivor spaces until it decides they've been there long enough, at which point it copies them into the old generation.PS Scavenge (enabled with -XX:+UseParallelGC)
the parallel scavenge collector, like the Copy collector, but uses multiple threads in parallel and has some knowledge of how the old generation is collected (essentially written to work with the serial and PS old gen collectors).ParNew (enabled with -XX:+UseParNewGC)
the parallel copy collector, like the Copy collector, but uses multiple threads in parallel and has an internal 'callback' that allows an old generation collector to operate on the objects it collects (really written to work with the concurrent collector).G1 Young Generation (enabled with -XX:+UseG1GC)
the garbage first collector, uses the 'Garbage First' algorithm which splits up the heap into lots of smaller spaces, but these are still separated into Eden and Survivor spaces in the young generation for G1.Old generation collectors
MarkSweepCompact (enabled with -XX:+UseSerialGC)
the serial mark-sweep collector, the daddy of them all, uses a serial (one thread) full mark-sweep garbage collection algorithm, with optional compaction.PS MarkSweep (enabled with -XX:+UseParallelOldGC)
the parallel scavenge mark-sweep collector, parallelised version (i.e. uses multiple threads) of the MarkSweepCompact.ConcurrentMarkSweep (enabled with -XX:+UseConcMarkSweepGC)
the concurrent collector, a garbage collection algorithm that attempts to do most of the garbage collection work in the background without stopping application threads while it works (there are still phases where it has to stop application threads, but these phases are attempted to be kept to a minimum). Note if the concurrent collector fails to keep up with the garbage, it fails over to the serial MarkSweepCompact collector for (just) the next GC.G1 Mixed Generation (enabled with -XX:+UseG1GC)
the garbage first collector, uses the 'Garbage First' algorithm which splits up the heap into lots of smaller spaces.
年轻一代收藏家
复制(通过 -XX:+UseSerialGC 启用)
串行复制收集器,使用一个线程将幸存的对象从 Eden 复制到 Survivor 空间以及在 Survivor 空间之间复制,直到它确定它们已经存在足够长的时间,此时它将它们复制到老一辈。PS Scavenge(使用 -XX:+UseParallelGC 启用)
并行清理收集器,类似于 Copy 收集器,但并行使用多个线程,并且对如何收集老年代有一些了解(主要编写用于串行和 PS 老代收藏家)。ParNew(使用 -XX:+UseParNewGC 启用)
并行复制收集器,与复制收集器类似,但并行使用多个线程并具有内部“回调”,允许旧代收集器对其收集的对象进行操作(真正写入与并发收集器一起工作)。G1 年轻代(使用 -XX:+UseG1GC 启用)
垃圾优先收集器,使用“垃圾优先”算法将堆分成许多更小的空间,但这些空间在年轻代中仍然分为 Eden 和 Survivor 空间G1。老一代收藏家
MarkSweepCompact(使用 -XX:+UseSerialGC 启用)
串行标记清除收集器,它们的老爹,使用串行(单线程)全标记清除垃圾收集算法,可选压缩。PS MarkSweep(使用 -XX:+UseParallelOldGC 启用)
并行清除标记-清除收集器,MarkSweepCompact 的并行版本(即使用多线程)。ConcurrentMarkSweep(使用 -XX:+UseConcMarkSweepGC 启用)
并发收集器,一种垃圾收集算法,它尝试在后台完成大部分垃圾收集工作,而不会在运行时停止应用程序线程(仍有一些阶段必须停止应用程序线程) ,但这些阶段试图保持在最低限度)。请注意,如果并发收集器无法跟上垃圾,它会故障转移到串行 MarkSweepCompact 收集器以(仅)下一次 GC。G1 混合生成(使用 -XX:+UseG1GC 启用)
垃圾优先收集器,使用“垃圾优先”算法将堆分成许多更小的空间。