4
votes

I thought, that in Java-Heap-Memory model

  • Survivor and
  • Old Gen

are synonymous. That it would be the area, where Java puts Object, which survived some GC Cycles.
In VisualVM I see, that these are two different areas and that even there are multiple Survivor areas.

What is the difference between Survivor and Old Gen areas in java memory?enter image description here

EDIT:

It seems, that Survivor (together with Eden) belongs to Young Gen, See enter image description here

1

1 Answers

6
votes

There are two survivor areas, S0 and S1. At any time, one of them are the from space or to space.

When a Minor GC happens, it collects objects from Eden space and the survivors are placed in the to space.

Objects from the previous GC, which are in the from space are also moved to the to space, unless they've reached a survivor threshold, which means this object is a long living object. In this case it is promoted to the Old Generation instead.

After this, the survivor spaces are swapped, so the to space is always clear.

There are only two survivor spaces. In the image, the Spaces and Graphs areas are just different representations of the same information.

You can read more about this here.