Wednesday 5 June 2019

Java: Card Tables

In my previous post, I explained about different garbage collection algorithms, young generation, old generation, permanent generation and meta space.




S0 stands for Survivor space 1
S1 stands for Survivor space 2.
Garbage collector performs garbage collection on young generation more frequently as compared to old generation. Since old generation cleaning takes some time which impacts performance.


What if an object in old generation refers to an object in young generation?

Garbage collector needs to scan all the objects in old generation to identify the objects that are refers to an object in young generation. This defeats the purpose of generation approach.

What is a Card table?
Card table is a table kind of data structure, where each one of its entry corresponds to 512 bytes of memory.  Card tables are used to identify which objects in young generation are referred by the objects in old generation.

JVM solves above problem by using write barriers and card table. When an object in old generation pointing to a reference to an object in the young generation, this action goes through write barrier. When JVM sees any update in write barriers, it updates the corresponding entry in the card table.
Previous                                                 Next                                                 Home

No comments:

Post a Comment