7.2.4 Saving objects
The activity of moving those Java objects whose age has not reached the threshold value to the Tenured area, is called Saving. Saving occurs when the number of in-use objects in the Eden area and the From space increase and the memory size of the To space, where these objects will be moved to, is not sufficient to hold those objects during copy GC. In such a case, the objects that could not move to the To space move to the Tenured area.
|
|
When the objects are saved, the objects with a short lifespan that originally were not supposed to be saved in the Tenured area, get saved in the Tenured area. If this process repeats, objects that were meant to be collected by copy GC remain in the memory space. This increases the memory usage of the Java heap, ultimately triggering Full GC.
The following figure shows the change in memory usage when the objects are saved:
|
|
In Full GC, a system might stop from a few seconds to 10 seconds.
As a result, when determining the configuration of the memory space and memory size, you must achieve a balance between the Eden area and the Survivor area, so that the objects are not saved.