How actually card table and writer barrier works?

后端 未结 3 2057
感动是毒
感动是毒 2020-12-12 18:31

I am reading some materials about garbage collection in Java in order to get to know more deeply what really happens in GC process.

I came across on the mechanism ca

3条回答
  •  清歌不尽
    2020-12-12 18:54

    Sometime ago I have written an article explaining mechanics of young collection in HotSpot JVM. Understanding GC pauses in JVM, HotSpot's minor GC

    Principle of dirty card write-barrier is very simple. Each time when program modifies reference in memory, it should mark modified memory page as dirty. There is a special card table in JVM and each 512 byte page of memory has associated one byte entry in card table.

    Normally collection of all references from old space to young would require scanning through all objects in old space. That is why we need write-barrier. All objects in young space have been created (or relocated) since last reset of write-barrier, so non-dirty pages cannot have references into young space. This means we can scan only object in dirty pages.

提交回复
热议问题