`

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(ConcurrentMarkSweep)垃圾回收器Java开发Java经验技巧共3页.pdf.zip

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

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

    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

    Java应用的垃圾回收优化

    这些方法包括但不局限于以下几点:并发标记清除(Concurrent Mark Sweep,CMS)和G1垃圾回收器的CPU和内存开销,避免长期存活对象引起的持续GC周期,优化GC线程任务分配使性能提升,以及GC停顿时间可预测所需的OS设置。

    jdk-14_linux-x64_bin.rpm

    363:Remove the Concurrent Mark Sweep (CMS) Garbage Collector 移除 CMS(Concurrent Mark-Sweep) 垃圾回收器。 364:ZGC on macOS 将 ZGC 垃圾回收器移植到 macOS。 365:ZGC on Windows 将 ZGC ...

    java7帮助文档

    Garbage-First Collector is a server-style garbage collector that replaces the Concurrent Mark-Sweep Collector (CMS). Java HotSpot Virtual Machine Performance Enhancements JDBC 4.1 JDBC 4.1 ...

    Android studio4.1 dart fluter插件

    Android studio4.1 dart fluter插件 Android Studio 4.1 Build #AI-201.8743.12.41.6858069, built on September 23, 2020 ...GC: ParNew, ConcurrentMarkSweep Memory: 3038M Cores: 4 Registry: ide.new.we

    QiYuTkAndroid:奇遇淘客Android版本

    奇遇淘客Android版 奇遇淘客代码库 奇遇淘客文档 博客文章 编译环境 ...GC: ParNew, ConcurrentMarkSweep Memory: 1981M Cores: 8 Registry: ide.new.welcome.screen.force=true, external.system.au

    AndroidThreeWins

    AndroidThreeWins此应用程序是一个TicTacToe克隆。... ParNew,ConcurrentMarkSweep内存:1246M内核:4注册表:ide.new.welcome.screen.force = true,external.system.auto.import.disabled = true日期:16.03.2021

    降低Java垃圾回收开销的5条建议

    保持GC低开销的窍门有哪些?  随着一再拖延而即将发布的 Java9,G1(“Garbage First”)垃圾回收器将被成为 HotSpot 虚拟机默认的垃圾回收器。...CMS(“Concurrent Mark-Sweep”)收集器与 parallel GC 相比,它将回收过

    werewolfGame:《我的世界》中的狼人游戏

    203.5981.155,于2020年12月1日构建运行时版本:11.0.9 + 11-b1145.21 x86_64 VM:JetBrains sro macOS 10.16 GC的OpenJDK 64位服务器VM :ParNew,ConcurrentMarkSweep内存:1981M内核:8个非捆绑式插件:...

    programming-erlang-software-for-a-concurrent-world

    Pragmatic Programmers,LLC was aware of a trademark claim,the designations have been printed in initial capital letters or in all capitals.The Pragmatic Starter Kit,The Pragmatic Programmer,Pragmatic ...

    JAVA虚拟机精讲

    Mark-Sweep)收集器和G1(Garbage-First)收集器)、类加载机制,以及HotSpot VM 基于栈的架构模型和执行引擎(解释器的工作流程、JIT 编译器的工作流程、分层编译策略、热点探测功能)等技术。

    Java虚拟机精讲.高翔龙.带书签完整版.pdf

    Mark-Sweep)收集器和G1(Garbage-First)收集器)、类加载机制,以及HotSpot VM 基于栈的架构模型和执行引擎(解释器的工作流程、JIT 编译器的工作流程、分层编译策略、热点探测功能)等技术。

    JAVA虚拟机精讲 pdf

    Mark-Sweep)收集器和G1(Garbage-First)收集器)、类加载机制,以及HotSpot VM 基于栈的架构模型和执行引擎(解释器的工作流程、JIT 编译器的工作流程、分层编译策略、热点探测功能)等技术。

    matlab终止以下代码-matlab-parallel-server-with-aws-batch:使用CloudFormation站对MA

    Toolbox:trade_mark:。 具有所需权限的AWS账户。 要查看所需内容,请查看。 有关使用的服务的更多信息,请参见。 使用说明 不支持带有AWS Batch的MATLAB Parallel Server。 费用表 使用本指南创建云资源时,您应对...

    java虚拟机精讲(电子工业出版社出版)

    Mark-Sweep)收集器和 G1(Garbage-First)收集器)、类加载机制,以及HotSpot VM 基于栈的架构模型和执行引擎(解释器的工作流程、JIT 编译器的工作流程、分层编译策略、热点探测功能)等技术。 第1 章 Java体系...

    [iPhone开发书籍大全].More.iPhone.3.Development.Tackling.iPhone.SDK.3(Apress.2009-12).pdf

    More iPhone 3 Development Tackling iPhone SDK 3,英文版本,PDF 格式,大小 9 Mb,作者:Dave Mark、Jeff LaMarche。 What you’ll learn All about Core Data: key concepts and techniques for writing larger ...

    C#4.0本质论(第3版)

    作者: Mark Michaelis 资源格式: PDF 版本: 英文文字版 出版社: Addison-Wesley Professional书号: 978-0321694690发行时间: 2010年03月 地区: 美国 语言: 英文 简介: 内容介绍: Essential C# 4.0已经是第三版...

Global site tag (gtag.js) - Google Analytics