JVM Minor GC

JVM Minor GC

7f408bc67dc9ae3b288ee92d16d3c4c2?s=128

Deepu K Sasidharan

January 23, 2020
Tweet

Transcript

  1. Minor GC 1. Let us assume that there are already

    objects on the Eden space when we start(Blocks 01 to 06 marked as used memory) 2. The application creates a new object(07) 3. JVM tries to get required memory from Eden space, but there is no free space in Eden to accommodate our object and hence JVM triggers minor GC
  2. Minor GC Heap memory Young generation Old generation (Tenured space)

    EDEN Survivor space S0 S1 01 02 03 04 05 06 07 (new object) Orphan Used memory Free memory
  3. Minor GC Heap memory Young generation Old generation (Tenured space)

    EDEN Survivor space S0 S1 01 02 03 04 05 06 07 (new object) Orphan Used memory Free memory
  4. Minor GC Heap memory Young generation Old generation (Tenured space)

    EDEN Survivor space To survivor space Orphan Used memory Free memory S1 01 02 03 04 05 06 07 (new object)
  5. Minor GC Heap memory Young generation Old generation (Tenured space)

    EDEN Survivor space To survivor space Orphan Used memory Free memory S1 01 03 05 07 (new object)
  6. Second Minor GC 1. Let us assume that some time

    have passed and there are more objects on the Eden space now(Blocks 07 to 13 marked as used memory) 2. The application creates a new object(14) 3. JVM tries to get required memory from Eden space, but there is no free space in Eden to accommodate our object and hence JVM triggers second minor GC
  7. Minor GC Heap memory Young generation Old generation (Tenured space)

    EDEN Survivor space S0 S1 01 08 09 10 11 13 14 (new object) Orphan Used memory Free memory 07 12 01 03 05
  8. Minor GC Heap memory Young generation Old generation (Tenured space)

    EDEN Survivor space From survivor space To survivor space 01 08 09 10 11 13 14 (new object) Orphan Used memory Free memory 07 12 01 03 05
  9. Minor GC Heap memory Young generation Old generation (Tenured space)

    EDEN Survivor space From survivor space To survivor space 08 09 11 14 (new object) Orphan Used memory Free memory 07 12 01 03 05 10 13
  10. Minor GC Heap memory Young generation Old generation (Tenured space)

    EDEN Survivor space From survivor space S1 14 (new object) Orphan Used memory Free memory 07 01 03 10 13 S0
  11. 13 more Minor GC cycles later 1. This keeps on

    repeating for each minor GC and the survivors are shifted between S0 and S1 and their age is incremented. Once the age reaches the "max age threshold", 15 by default, the object is moved to the "Tenured space"
  12. Minor GC Heap memory Young generation Old generation (Tenured space)

    EDEN Survivor space S0 S1 14 Orphan Used memory Free memory 25 03 10 13 01 28 29