Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concurrent Mark and Sweep algorithm details

I am struggling to understand and get more details on the steps involved in CMS tenured collection cycles.

  1. Initial Mark
  2. Concurrent Mark
  3. Concurrent pre-clean
  4. Re-mark
  5. Concurrent Sweep
  6. Concurrent Reset

These steps are explained in lot of places in very short. But if I have to describe them in a class with diagrams and psuedo-examples where can I get that information from?

PS - I have searched extensively on Google, it throws up with a lot of textual stuff and jargon which I understand. But I am looking for a more animated explanation so that I can teach my audience.

These are some of the links which are popular, the 3rd one was very promising but it failed to explain the CMS in particular

  1. http://www.infoq.com/articles/Java_Garbage_Collection_Distilled
  2. http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html
  3. http://www.cubrid.org/blog/dev-platform/understanding-java-garbage-collection/

Dear all, thanks for commenting and pointing me to some resources. I have tried to create a visual representation of the CMS steps, can you please let me know if this matches your understanding ?

Also I seem to be missing the Compacting step, which step does it belong to ?

Answer : Ok so compacting is not handled by CMS, instead it is delegated to full GC.

Stages of CMS GC

like image 787
Bhushan Avatar asked May 27 '14 07:05

Bhushan


People also ask

How does concurrent mark sweep work?

The Concurrent Mark Sweep (CMS) implementation uses multiple garbage collector threads for garbage collection. It's designed for applications that prefer shorter garbage collection pauses, and can afford to share processor resources with the garbage collector while the application is running.

What is concurrent mark sweep generation?

Concurrent Mark-Sweep refers to the Garbage Collection alogorithm that is being used, in this case, to collect against the "old" heap. The heap is generally in 3 generations.

What is mark and sweep algorithm in JavaScript?

Mark-and-sweep algorithmThis algorithm assumes the knowledge of a set of objects called roots. In JavaScript, the root is the global object. Periodically, the garbage collector will start from these roots, find all objects that are referenced from these roots, then all objects referenced from these, etc.

How does CMS garbage collection work?

The CMS collector attempts to reduce pause times due to major collections by using separate garbage collector threads to trace the reachable objects concurrently with the execution of the application threads.


1 Answers

Starting java 1.5, there is another phase that is missed out is the "concurrent abortable preclean". It aims to delay the remark until there is a desired occupancy is achieved in the Eden space.

Other than that you are pretty much on track.

I suggest you look at this old oracle gc whitepaper and this step by step description of the CMS gc logs . It confirms the steps you have put in the images.

This blog post summarizes things well.

like image 126
Aditya Avatar answered Sep 25 '22 09:09

Aditya