`
netcome
  • 浏览: 479592 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Concurrent mark

    博客分类:
  • JAVA
阅读更多

Concurrent mark gives reduced and consistent garbage collection pause times when heap sizes increase.

The GC starts a concurrent marking phase before the heap is full. In the concurrent phase, the GC scans the roots, i.e. stacks, JNI references, class statics, and so on. The stacks are scanned by asking each thread to scan its own stack. These roots are then used to trace live objects concurrently. Tracing is done by a low-priority background thread and by each application thread when it does a heap lock allocation.

While the GC is marking live objects concurrently with application threads running, it has to record any changes to objects that are already traced. It uses a write barrier that is run every time a reference in an object is updated. The write barrier flags when an object reference update has occurred, to force a re-scan of part of the heap. The heap is divided into 512-byte sections and each section is allocated a one-byte card in the card table. Whenever a reference to an object is updated, the card that corresponds to the start address of the object that has been updated with the new object reference is marked with 0x01. A byte is used instead of a bit to eliminate contention; it allows marking of the cards using non-atomic operations. A stop-the-world (STW) collection is started when one of the following occurs:
  • An allocation failure
  • A System.gc
  • Concurrent mark completes all the marking that it can do

The GC tries to start the concurrent mark phase so that it completes at the same time as the heap is exhausted. The GC does this by constant tuning of the parameters that govern the concurrent mark time. In the STW phase, the GC re-scans all roots and uses the marked cards to see what else must be retraced, and then sweeps as normal. It is guaranteed that all objects that were unreachable at the start of the concurrent phase are collected. It is not guaranteed that objects that become unreachable during the concurrent phase are collected. Objects which become unreachable during the concurrent phase are referred to as "floating garbage".

Reduced and consistent pause times are the benefits of concurrent mark, but they come at a cost. Application threads must do some tracing when they are requesting a heap lock allocation. The processor usage needed varies depending on how much idle CPU time is available for the background thread. Also, the write barrier requires additional processor usage.

The -Xgcpolicy command-line parameter is used to enable and disable concurrent mark:

-Xgcpolicy: <optthruput | optavgpause | gencon | subpool>

The -Xgcpolicy options have these effects:
optthruput
Disables concurrent mark. If you do not have pause time problems (as seen by erratic application response times), you get the best throughput with this option.Optthruput is the default setting.
optavgpause
Enables concurrent mark with its default values. If you are having problems with erratic application response times that are caused by normal garbage collections, you can reduce those problems at the cost of some throughput, by using the optavgpause option.
gencon
Requests the combined use of concurrent and generational GC to help minimize the time that is spent in any garbage collection pause.
subpool
Disables concurrent mark. It uses an improved object allocation algorithm to achieve better performance when allocating objects on the heap. This option might improve performance on SMP systems with 16 or more processors. The subpool option is available only on AIX®, Linux® PPC and zSeries®, z/OS®, and i5/OS®.

分享到:
评论

相关推荐

    了解CMS(ConcurrentMarkSweep)垃圾回

    【CMS(Concurrent Mark Sweep)垃圾回收器】是Java虚拟机(JVM)中的一种垃圾收集器,专门针对老年代的内存管理。CMS回收器的主要目标是减少垃圾收集时的应用程序暂停时间,以提高用户体验。它引入了并发模式,允许...

    gc-notification-utils:捕捉真正的 stop-the-world ConcurrentMarkSweep 时间!

    捕获真正的 stop-the-world ConcurrentMarkSweep 时间,而不是第一个 CMS 阶段开始到最后一个阶段结束之间的挂钟时间。 使用此工具,您可以测量应用程序在 CMS 的两个停止世界阶段(初始标记、重新扫描)期间失效...

    JvmGC收集器

    JvmGC 收集器是 JVM 中的三个主要 GC 收集器之一,分别是 Serial GC、Parallel GC 和 Concurrent Mark-and-Sweep GC。 Serial GC Serial GC 是 JVM 默认的 GC 收集器,它使用单个线程来执行 GC 操作。这种 GC 适合...

    lombok-plugin-0.30-2020.1foridea.zip

    IDEA离线安装插件lombok-plugin-0.30-2020.1,请与idea版本对应好。 IntelliJ IDEA 2020.1.2 (Ultimate Edition) ...GC: ParNew, ConcurrentMarkSweep Memory: 989M Cores: 8 Non-Bundled Plugins: Lombook Plugin

    JVM中CMS收集器1

    CMS(Concurrent Mark Sweep)收集器,全称为"Mostly Concurrent Mark and Sweep Garbage Collector",是Java虚拟机(JVM)中一种旨在减少老年代(Old Generation)垃圾回收时停顿时间的并发垃圾收集器。它采用了...

    golang 50k 高阶面试题

    而提供的部分内容,则详细介绍了CMS(Concurrent Mark-Sweep)垃圾回收器的面试常见问题,包括其工作原理、特点和面试官可能探询的方向。 在Java虚拟机(JVM)中,CMS垃圾回收器是一种以获取最短回收停顿时间为目标...

    JDK18-hotspot-virtual-machine-garbage-collection-tuning-gui

    HotSpot 虚拟机提供了多种垃圾回收算法,包括 Serial GC、Parallel GC、Concurrent Mark-and-Sweep GC 和 G1 GC 等。每种算法都有其优缺,选择合适的算法对垃圾回收性能的影响很大。 垃圾回收参数调整 ------------...

    Java理解CMS收集器.pdf

    CMS(Concurrent Mark Sweep)收集器是Java虚拟机中的一种垃圾收集器,主要针对老年代的内存回收,其特点是并发和低停顿。CMS收集器的主要目标是在尽可能短的时间内完成垃圾收集,减少应用程序的暂停时间,提高用户...

    Oracle-HotSpot Virtual Machine Garbage Collection.pdf

    Oracle HotSpot Virtual Machine 中使用了多种垃圾回收算法,包括 Serial GC、Parallel GC、Concurrent Mark-and-Sweep (CMS) GC、G1 GC 等。这些算法的选择取决于应用程序的具体需求和性能要求。 Serial GC 是最...

    从ES的JVM配置起步思考JVM常见参数优化

    在过去,CMS (Concurrent Mark-Sweep) 垃圾回收器在Java 8中是一种常见选择,因为它在某些场景下能够提供较好的性能。 然而,随着Java版本的不断更新,一些旧的特性和组件被淘汰或替代,比如CMS。Java 14中正式废弃...

    JVM垃圾收集器全面详解

    ParNew是Serial GC的多线程版本,主要在新生代进行工作,与CMS(Concurrent Mark Sweep)垃圾收集器配合使用,适合多CPU环境。它可以减少暂停时间,但可能会增加CPU使用率。 3. **Parallel GC** Parallel GC也...

    02垃圾回收器1

    ParNew通常会与Serial Old或CMS(Concurrent Mark Sweep)收集器配合使用,其中Serial Old用于老年代的回收,而CMS则提供了并发的垃圾收集策略,减少了应用程序的暂停时间。 Parallel Scavenge收集器,与ParNew类似...

    Java垃圾收集必备手册

    在 Java 语言中,垃圾收集器的实现可以分为 serial GC、parallel GC 和 concurrent mark-and-sweep GC 等几种方式。 垃圾收集优化 垃圾收集优化是指对垃圾收集器的优化,以提高垃圾收集的效率和性能。垃圾收集优化...

    Java 垃圾回收机制详解及实例代码.docx

    - **增量/并发垃圾回收(Incremental/Concurrent Marking)**:为了减少垃圾回收期间应用程序的停顿时间,这些算法尝试在多个步骤中完成标记过程,与应用程序线程交错执行,如CMS(Concurrent Mark Sweep)和G1...

    Dalvik虚拟机垃圾收集过程分析.doc

    然而,随着Android系统的演进,后来的版本如ART(Android RunTime)引入了更高效的垃圾收集机制,如CMS(Concurrent Mark Sweep)和G1(Garbage-First),以进一步提升性能和减少应用暂停时间。 总的来说,Dalvik...

    JVM中[垃圾回收器]的所有内容-pdf

    4. **CMS回收器**(Concurrent Mark Sweep):以低延迟为目标,尽量减少应用程序的暂停时间,通过并发地执行大部分垃圾回收任务。然而,在CMS的最终压缩阶段,仍然需要STW。 5. **G1回收器**(Garbage-First):...

    Garbage Collection

    Java提供了多种垃圾收集器,如Serial GC、Parallel GC、Concurrent Mark Sweep (CMS) GC、G1 GC等,它们各有特点,适用于不同的场景。 - **Serial GC**:单线程执行,适合轻量级应用或客户端环境。 - **Parallel ...

    自己的系统的gc参数学习

    不同的JVM版本提供了多种GC实现,例如Serial、Parallel、Concurrent Mark Sweep (CMS) 和G1 (Garbage-First) 等。G1收集器是Oracle JDK 1.8引入的一种新一代的垃圾收集器,旨在提供更可预测的暂停时间,适用于大型...

    堆栈溢出1

    在 JVM 中,垃圾回收机制有多种算法,如 Mark-Sweep 算法、Concurrent Mark-Sweep 算法、G1 算法等。不同的算法适用于不同的场景。 在 Java 中,我们可以使用 jvisualvm 工具来监控 JVM 的垃圾回收情况。jvisualvm ...

Global site tag (gtag.js) - Google Analytics