I used System. gc(), which undoubtedly triggered FullGC.
Why does triggering FullGC cause objects in eden to move to old gen?.
I think only YGC would move objects to old gen.
jdk1.8 -Xms20m -Xmx20m -XX:+UseSerialGC
byte[] b1 = new byte[1024*1024];
byte[] b2 = new byte[1024*1024];
System.gc();
log:
{Heap before GC invocations=0 (full 0):
def new generation total 6144K, used 3677K [0x00000000fec00000, 0x00000000ff2a0000, 0x00000000ff2a0000)
eden space 5504K, 66% used [0x00000000fec00000, 0x00000000fef97768, 0x00000000ff160000)
from space 640K, 0% used [0x00000000ff160000, 0x00000000ff160000, 0x00000000ff200000)
to space 640K, 0% used [0x00000000ff200000, 0x00000000ff200000, 0x00000000ff2a0000)
tenured generation total 13696K, used 0K [0x00000000ff2a0000, 0x0000000100000000, 0x0000000100000000)
the space 13696K, 0% used [0x00000000ff2a0000, 0x00000000ff2a0000, 0x00000000ff2a0200, 0x0000000100000000)
Metaspace used 3102K, capacity 4496K, committed 4864K, reserved 1056768K
class space used 336K, capacity 388K, committed 512K, reserved 1048576K
Heap after GC invocations=1 (full 1):
def new generation total 6144K, used 0K [0x00000000fec00000, 0x00000000ff2a0000, 0x00000000ff2a0000)
eden space 5504K, 0% used [0x00000000fec00000, 0x00000000fec00000, 0x00000000ff160000)
from space 640K, 0% used [0x00000000ff160000, 0x00000000ff160000, 0x00000000ff200000)
to space 640K, 0% used [0x00000000ff200000, 0x00000000ff200000, 0x00000000ff2a0000)
tenured generation total 13696K, used 2645K [0x00000000ff2a0000, 0x0000000100000000, 0x0000000100000000)
the space 13696K, 19% used [0x00000000ff2a0000, 0x00000000ff5357e0, 0x00000000ff535800, 0x0000000100000000)
Metaspace used 3102K, capacity 4496K, committed 4864K, reserved 1056768K
class space used 336K, capacity 388K, committed 512K, reserved 1048576K
}
Obviously, the old gen occupies 0mb before GC, and the eden occupies 0mb after GC.
qwee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.