Upload
keyup
View
175
Download
0
Embed Size (px)
Citation preview
Garbage Collection in Java
Ondřej Kratochvíl
▷ 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
▷ 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
▷ 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
▷ 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
Díky za pozornost!Otázky?
Ondřej Kratochví[email protected]