java - Garbage collection: Initial marking and concurrent marking -
for concurrent-mark-sweep garbage collector in java; i'm not clear different between these 2 phases. why concurrent marking needed ? did initial marking not find live objects ?
cms used, called 3-color marking algorithm marking live objects.
- white - unmarked
- gray - object marked, outbound references not processed
- black - object marked , outbound references processed
marking starts graying out objects reachable roots, , considered finished when no more gray objects available.
concurrent marking in cms marking in old space only. references outside of old space root references.
they are
- local variables available thread stacks
- references young space old
as old space suitable concurrent marking, stacks , young space should precessed in stop-the-world fashion. constitutes initial-mark
phase of cms.
once initial-mark
finish cms have number of grayed objects in old space start concurrent marking. during concurrent marking black objects may revert gray if modified application threads. card marking writer barrier allow cms track modification.
finally cms doing stop-the-world pause remark
. remark rescans stack , young space again , finished marking of old space (most reachable objects black marking quick). young space , stacks not tracked write barrier, cms have rescan them find new references old space.
after remark
finished there black , white objects in old space, sweeping can proceed.
you can read more details cms collector in this article.
Comments
Post a Comment