6
Garbage Collection in Java Ondřej Kratochvíl

Garbage Collection in Java

  • Upload
    keyup

  • View
    175

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Garbage Collection in Java

Garbage Collection in Java

Ondřej Kratochvíl

Page 2: Garbage Collection in Java

▷ YoungAllocation of new objectsOften collectedMinor garbage collection when full - Stop the World event

▷ OldStores long surviving objects (also Stop the World)Major garbage collection

JVM Generations

Page 3: Garbage Collection in Java

▷ Permanent (Tenured)Metadata for JVM

class/method descriptorsData stored at runtime based on classes in useCan be collected - when space is needed and JVM does no

longer need some old classesincluded in Full garbage collection

JVM Generations

Page 4: Garbage Collection in Java

▷ New object is allocated in New generation in eden space

▷ When eden space fills up, minor GC is triggered

Referenced objects are moved to first survivor space, age++

▷ At the next minor GC, referenced objects are moved to

SECOND survivor space

▷ After each minor GC, the spaces switch

▷ If referenced object’s age > threshold, it gets promoted to

Old generation

GC Process - Young generation

Page 5: Garbage Collection in Java

▷ Serial GC

Mark-Sweep-Compact algorithm in the old generation

For small memory/small amount of CPU cores

▷ Parallel GC (Throughput GC)

Multithreaded for young generation

▷ Parallel Old GC

Parallel for both generations

▷ CMS GC (Concurrent mark-sweep)

Low pause time

Objects are swept while other are still being marked

GC types

Page 6: Garbage Collection in Java

Díky za pozornost!Otázky?

Ondřej Kratochví[email protected]