Question regarding the need for From/To spaces (vs. simply compacting).
jon.masamitsu at oracle.com
Wed Jun 23 07:12:28 PDT 2010
A copying collector finds live objects (starting at the roots - known
references to objects such as on thread stacks) and then copies
them to somewhere. If you just had a single space, you would not
know where to copy the object to (i.e., where in the space is there room
to copy the object so that you don't copy over other live objects).
To-space is typically empty at the start of a collection so you know
you're not tromping over live objects.
On 06/23/10 02:47, Dawid Weiss wrote:
> Hello there,
> A friend of mine asked me a question that I couldn't find any sensible
> answer for both in literature, on the Web and by browsing through
> OpenJDK source code (but this, I admit, is not easy considering the
> volume of code there). The question is:
> "Why is the young gen. split between to/from spaces, so that the GC
> must copy everything back and forth between two memory regions if only
> a single monolithic space would suffice for compacting live objects?"
> The only thing I could tell him was that this design decision could be
> motivated by the fact that:
> - the implementation is simplified since the copied objects end up
> either in the TO space or are promoted somewhere else (in case of a
> generational GC),
> - the implementation may be paralellized to compact concurrently and
> then merge the compacted segments (assumption by looking at
> psYoungGen.cpp's move_and_update method).
> No other clues from me. If I'm missing something obvious (which is
> probably the case), then an RTFM with a pointer would be great.
More information about the hotspot-gc-dev