problem description
set the heap size to 20MB, and the heap size of the younger generation is 8:1
to generate 2MB of main () 2MB alcation4 objects
A MinorGC occurs when executing the statement to allocate alcation4 objects in the heap. The reason for this GC is that when the memory is allocated to the allocation4, it is found that the Eden has been occupied by 6MB, and the remaining space is not enough to allocate the 4MB memory needed by the allocation4, so Minor GC occurs. During GC, the virtual machine found that the existing three 2MB-sized objects could not be stored in Surivor space (the Survor space was only the size of 1MB), so it had to be transferred to the old era ahead of time through the allocation guarantee mechanism.
related codes
operating environment: jdk1.8.0_151
java Parameter:-verbose:gc-Xms20M-Xmx20M-Xmn10M-XX:+PrintGCDetails-XX:SurvivorRatio=8