Usage:
The option “-XX:[+|-]UseCondCardMark” Enables checking if the card is already marked before updating the card table.
Since:
Starting from JDK 6.
Syntax:
java -XX:[+|-]UseCondCardMark MainClass
Description:
Before talking about the flag, we need to introduce Garbage Collector (GC) and Card Marking:
Garbage Collector is a way of the JVM to clean the memory and makes the java memory more efficient. It tracks (Mark step) and removes (sweep step) every unused object available in the JVM heap space. An object is considered unused when it’s referenced by null, assigned to another reference or by anonymous object ….
In modern JVMs, the heap space is usually divided into young and old generations. Since the garbage collection of the young generation is usually very frequent, if the old generation objects refer to the young generation objects, then all references from the old generation to the young generation need to be tracked, so as to avoid scanning the entire old generation every time YGC, and reduce overhead, JVM has introduced Card Marking
For the HotSpot JVM, Card Marking technology is used to solve the reference problem from the old generation to the young generation. Specifically, use the Card Table and Write Barrier to mark and speed up the scanning of GC Roots. most managed heap environments use a card table to mark regions of memory where writes have occurred. However, this method can be fatal if the memory is written to by multiple processors, as adjacent cards are written to require writing to adjacent bytes in the card table.
Fortunately, JVM introduced the flag “UseCondCardMark” which enables/disables the implementation of card table dirty byte writes by first checking if the byte is set and only setting it if not. This way memory contention only happens during the first write to that card. After that, only reads to that cache line will occur. Since cache lines are only read, they can be replicated across multiple processors and do not need to be synchronized for reads.
Default Value:
This option is disabled by default.
Note:
This flag can increase (depending on the OS) execution time by about 15-20% for 1 thread and only the Java HotSpot Server VM supports this option.
Errors:
None.
Related Posts:
Edit your Comment