Java Reference
In-Depth Information
generation collection, objects are moved from eden into survivor space 0. During the next
collection, live objects are moved from both survivor space 0 and from eden into survivor
space 1. At that point, eden and survivor space 0 are completely empty. The next collection
moves live objects from survivor space 1 and eden into survivor space 0, and so on. (The
survivor spaces are also referred to as the “to” and “from” spaces; during each collection, ob-
jects are moved out of the “from” space into the “to” space. “from” and “to” are simply
pointers that switch between the two survivor spaces on every collection.)
Clearly this cannot continue forever, or nothing would ever be moved into the old generation.
Objects are moved into the old generation in two circumstances. First, the survivor spaces
are fairly small. When the target survivor space fills up during a young collection, any re-
maining live objects in eden are moved directly into the old generation. Second, there is a
limit to the number of GC cycles during which an object can remain in the survivor spaces.
That limit is called the tenuring threshold.
There are tunings to affect each of those situations. The survivor spaces take up part of the
allocation for the young generation, and like other areas of the heap, the JVM sizes them dy-
namically. The initial size of the survivor spaces is determined by the -
XX:InitialSurvivorRatio= N flag, which is used in this equation:
survivor_space_size = new_size / (initial_survivor_ratio + 2)
For the default initial survivor ratio of 8, each survivor space will occupy 10% of the young
The JVM may increase the survivor spaces size to a maximum determined by the setting of
the -XX:MinSurvivorRatio= N flag. That flag is used in this equation:
maximum_survivor_space_size = new_size / (min_survivor_ratio + 2)
By default, this value is 3, meaning the maximum size of a survivor space will be 20% of the
young generation. Note again that the value is a ratio, so the minimum value of the ratio
gives the maximum size of the survivor space. The name is hence a little counterintuitive.
To keep the survivor spaces at a fixed size, set the SurvivorRatio to the desired value and
disable the UseAdaptiveSizePolicy flag (though remember that disabling adaptive sizing
will apply to the old and new generations as well).
Search WWH ::

Custom Search