If the young generation of the heap is too small, objects
that could have been allocated then collected quickly, and allocated to
the old generation where they remain until a full garbage collection is
triggered. This wastes space in the heap.
If the young generation of the heap is too large, the garbage
collection runs longer than necessary. This is because when the total size
of the objects in the young generation is larger than the available space
in the old generation, a full garbage collection is triggered instead.
The Java Virtual Machine cannot transfer all objects in the young
generation to the old generation during the incremental (minor) garbage
collection when there is not enough room in the old generation. This
triggers a full garbage collection to free space in the old generation
portion of the heap.
This scenario is officially known as violation of the young generation
Guarantee. If the young generation is too large, full garbage
collections occur too often and incremental garbage collections occur too
infrequently.
|