Upgrade to Pro — share decks privately, control downloads, hide ads and more …

JVM Minor GC

JVM Minor GC

Deepu K Sasidharan

January 23, 2020
Tweet

More Decks by Deepu K Sasidharan

Other Decks in Education

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

    View full-size slide

  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

    View full-size slide

  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

    View full-size slide

  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)

    View full-size slide

  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)

    View full-size slide

  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

    View full-size slide

  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

    View full-size slide

  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

    View full-size slide

  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

    View full-size slide

  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

    View full-size slide

  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"

    View full-size slide

  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

    View full-size slide