SlideShare uma empresa Scribd logo
1 de 33
Java Team
Introduction to Garbage
Collection
OpenJDK: Automatic Memory Management
Monica Beckwith
JVM Performance
java-performance@Microsoft
@mon_beck
Agenda
What is Garbage Collection (GC)?
Allocation, Reclamation == Memory Management
Techniques of Automatic Memory Management
A Few GC Algorithms in OpenJDK HotSpot VM
July 1st , 2020
What We Will Try To Cover Today
Garbage Collection aka
Memory Management
==
Allocation
+
Reclamation
Allocation: The Manual Way …
Allocation Space
Allocations Happen …
O O O O O O O O O O
O O O O O O O
O O O O O O O O
Space Gets Filled Up
O O O O O O O O O O
O O O O O O O O O O
O O O O O O O O O O
O O O O O O O O O
O O O O O O O O O
O O O O O O O O O
Its Marking Time!
Root Set
O
O
O
O
O
O O O O O O O O O O
O O O O O O O O O O
O O O O O O O O O O
O O O O O O O O O
O O O O O O O O O
O O O O O O O O O
Its Marking Time! – Tracing from the Root Set
Its Marking Time! – Creating Live Object Graph
Root Set
O
O
O
O
O
O O O O O O O O O O
O O O O O O O O O O
O O O O O O O O O O
O O O O O O O O O
O O O O O O O O O
O O O O O O O O O
Ready to Reclaim?
Root Set
O
O
O
O
O
O O O O O
O O O O O O O O
O O O O O O O O
O O O O O O O O O
O O O O O O O O O
O O O O O O O O O
O O O O O O O O O O
O O O O O O O O O O
O O O O O O O O O O
Ready to Reclaim? – Are We Done?
Manual Reclamation – Problem!
Root Set
O
O
O
O
O
O O O O O
O O O O O O O O
O O O O O O O
O O O O O O O O O
O O O O O O O O O
O O O O O O O O O
This can leadto a
memory leak!!
Manual Reclamation – Problem: Memory Leak
Root Set
O
O
O
O
O
O O O O O
O O O O O O O O
O O O O O O O
O O O O O O O O O
O O O O O O O O O
O O O O O O O O O
Manual Reclamation – Problem!
Root Set
O
O
O
O
O
O O O O O
O O O O O O O O
O O O O O O O
O O O O O O O O O
O O O O O O O O O
O O O O O O O O
Two dangling
pointers!!
Manual Reclamation – Problem: Dangling Pointers
So What Can We Do?
Stack Based Allocation:
- Push and pop will take care of the issues
- E.g. Java bytecode interpreter
Hybrid Allocation:
- These typically combine region-based allocation with reference
counting or tracing garbage collection
- E.g. OpenJDK GCs using Thread Local Allocation Buffers (TLABs)
Reference Counting vs Tracing
“The Continuous Tracker” Active When Full Or When Threshold Crossed
Basic Considerations of Automatic Memory
Management
Collection Efficiency
- It maybe more efficient to leave some garbage around
- E.g. G1 GC’s incremental compaction / mixed collection
Performance Trifecta
- GC designs are based around responsiveness, footprint considerations
and throughput efficiency
- E.g. OpenJDK’s Serial GC for low footprint, Parallel GC for throughput
efficiency
Further Considerations …
Generational Hypothesis
- Most objects die young
- E.g. OpenJDK GCs other than ZGC and Shenandoah GC
Age Threshold
- Promote only the long-lived objects (including transients)
- E.g. OpenJDK’s generational collectors with survivor space
Groundwork : Heap
layout - regions and
generations
Heap Layout
Heap
Z GC
Shenandoah GC
Young Generation
G1 GC
Old Generation
Commonalities :
Copying collector –
from and to spaces From To
HeapFrom Space To Space
O O O O O O O O O O
O O O O O O O O O O
O O O O O O O O O O
GC ROOTS
THREAD
1 STACK
THREAD
N STACK
STATIC
VARIABLES
ANY JNI
REFERENCES
Copying Collector aka Compacting Collector aka
Evacuation
O O O O O O O O O O
O O O O O O O O O O
O O O O O O O O O O
GC ROOTS
THREAD
1 STACK
THREAD
N STACK
O O
O O
O
STATIC
VARIABLES
ANY JNI
REFERENCES
O
OO
O
O
O O O O O O O O O O
O O O O O O O O O O
O O O O O O O O O O
Copying Collector aka Compacting Collector aka
Evacuation
Copying Collector aka Compacting Collector aka
Evacuation
O O O O O O O O
O O O O O O O
O O O O O O O
O O O
O O O
O O
Commonalities : Regions
– occupied and free
Occupied and Free Regions
O O O O O O O O O O
O O O O O O O O O O
O O O O O O O O O O
O O O O
O O O O
O O O O
• List of free regions
• In case of generational heap (like G1), the occupied regions could be young, old or
humongous
Commonalities :
Collection set and
priority
Collection Priority and Collection Set
O O O O O O O O O O
O O O O O O O O O O
O O O O O O O O O O
O O O O
O O O O
O O O O
OO
OO
OO
OO
OO
OO
OO
OO
OO
O
OO
OO
OO
OO
OO
OO
OO
OO
OO
O
OOOO
• Priority is to reclaim regions with most garbage
• The candidate regions for collection/reclamation/relocation are said to be in a collection set
• There are threshold based on how expensive a region can get and maximum regions to
collect
• Efficiency: Incremental collection aka incremental compaction or partial compaction
• Usually needs a threshold that triggers the compaction
• Stops after the desired reclamation threshold or free-ness threshold is reached
• Doesn’t need to be stop-the-world
Introduction : G1,
Shenandoah & Z -
Algorithms
Algorithm and Other Considerations
Garbage Collectors G1 GC Shenandoah GC Z GC
Regionalized? Yes Yes Yes
Generational? Yes No No
Compaction? Yes, STW, Forwarding
address in header
Yes, Concurrent,
Forwarding Pointer
Yes, Concurrent,
Colored Pointers
Target Pause Times? 200ms 10ms 10ms
Concurrent Marking
Algorithm?
SATB SATB Striped
Further Reading
https://www.youtube.com/watch?v=VCeHkcwfF9Q
https://www.usenix.org/legacy/events/vee05/full_papers/p46-click.pdf
http://mail.openjdk.java.net/pipermail/zgc-dev/2017-December/000047.html
http://hg.openjdk.java.net/zgc/zgc/file/ffab403eaf14/src/hotspot/share/gc/z/zB
arrier.cpp
https://wiki.openjdk.java.net/display/zgc/Main
https://www.azul.com/files/c4_paper_acm1.pdf
© Copyright Microsoft Corporation. All rights reserved.
Stop-the-world aka STW GC
Application Threads
GC Threads
Application Threads
Safepoint
Requested
GC
Completed
Application Threads GC Threads Application Threads
Safepoint
Requested
GC
Completed
Handshakes
Thread local handshakes vs Global
Time To Safepoint
(TTSP)
Concurrent GC
Application Threads
GC Threads
© Copyright Microsoft Corporation. All rights reserved.

Mais conteúdo relacionado

Mais procurados

Enabling Java: Windows on Arm64 - A Success Story!
Enabling Java: Windows on Arm64 - A Success Story!Enabling Java: Windows on Arm64 - A Success Story!
Enabling Java: Windows on Arm64 - A Success Story!Monica Beckwith
 
Garbage Collection
Garbage CollectionGarbage Collection
Garbage CollectionEelco Visser
 
Instruction sets picc done by Priyanga KR
Instruction sets   picc done by Priyanga KRInstruction sets   picc done by Priyanga KR
Instruction sets picc done by Priyanga KRPriyangaKR1
 
Inside LoLA - Experiences from building a state space tool for place transiti...
Inside LoLA - Experiences from building a state space tool for place transiti...Inside LoLA - Experiences from building a state space tool for place transiti...
Inside LoLA - Experiences from building a state space tool for place transiti...Universität Rostock
 
John Richardson - 2015 - KyotoEBMT System Description for the 2nd Workshop on...
John Richardson - 2015 - KyotoEBMT System Description for the 2nd Workshop on...John Richardson - 2015 - KyotoEBMT System Description for the 2nd Workshop on...
John Richardson - 2015 - KyotoEBMT System Description for the 2nd Workshop on...Association for Computational Linguistics
 
Scala & Spark(1.6) in Performance Aspect for Scala Taiwan
Scala & Spark(1.6) in Performance Aspect for Scala TaiwanScala & Spark(1.6) in Performance Aspect for Scala Taiwan
Scala & Spark(1.6) in Performance Aspect for Scala TaiwanJimin Hsieh
 
G1 Garbage Collector - Big Heaps and Low Pauses?
G1 Garbage Collector - Big Heaps and Low Pauses?G1 Garbage Collector - Big Heaps and Low Pauses?
G1 Garbage Collector - Big Heaps and Low Pauses?C2B2 Consulting
 
Assembly Language Lecture 5
Assembly Language Lecture 5Assembly Language Lecture 5
Assembly Language Lecture 5Motaz Saad
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051logesh waran
 
Sun jdk 1.6内存管理 -实现篇 -毕玄
Sun jdk 1.6内存管理 -实现篇 -毕玄Sun jdk 1.6内存管理 -实现篇 -毕玄
Sun jdk 1.6内存管理 -实现篇 -毕玄锐 张
 
G1 Garbage Collector: Details and Tuning
G1 Garbage Collector: Details and TuningG1 Garbage Collector: Details and Tuning
G1 Garbage Collector: Details and TuningSimone Bordet
 
Os Ghoshatanu
Os GhoshatanuOs Ghoshatanu
Os Ghoshatanuoscon2007
 
Lecture 14 run time environment
Lecture 14 run time environmentLecture 14 run time environment
Lecture 14 run time environmentIffat Anjum
 
Moving to g1 gc by Kirk Pepperdine.
Moving to g1 gc by Kirk Pepperdine.Moving to g1 gc by Kirk Pepperdine.
Moving to g1 gc by Kirk Pepperdine.J On The Beach
 

Mais procurados (17)

Enabling Java: Windows on Arm64 - A Success Story!
Enabling Java: Windows on Arm64 - A Success Story!Enabling Java: Windows on Arm64 - A Success Story!
Enabling Java: Windows on Arm64 - A Success Story!
 
Garbage Collection
Garbage CollectionGarbage Collection
Garbage Collection
 
Instruction sets picc done by Priyanga KR
Instruction sets   picc done by Priyanga KRInstruction sets   picc done by Priyanga KR
Instruction sets picc done by Priyanga KR
 
Inside LoLA - Experiences from building a state space tool for place transiti...
Inside LoLA - Experiences from building a state space tool for place transiti...Inside LoLA - Experiences from building a state space tool for place transiti...
Inside LoLA - Experiences from building a state space tool for place transiti...
 
John Richardson - 2015 - KyotoEBMT System Description for the 2nd Workshop on...
John Richardson - 2015 - KyotoEBMT System Description for the 2nd Workshop on...John Richardson - 2015 - KyotoEBMT System Description for the 2nd Workshop on...
John Richardson - 2015 - KyotoEBMT System Description for the 2nd Workshop on...
 
Scala & Spark(1.6) in Performance Aspect for Scala Taiwan
Scala & Spark(1.6) in Performance Aspect for Scala TaiwanScala & Spark(1.6) in Performance Aspect for Scala Taiwan
Scala & Spark(1.6) in Performance Aspect for Scala Taiwan
 
G1 Garbage Collector - Big Heaps and Low Pauses?
G1 Garbage Collector - Big Heaps and Low Pauses?G1 Garbage Collector - Big Heaps and Low Pauses?
G1 Garbage Collector - Big Heaps and Low Pauses?
 
Assembly Language Lecture 5
Assembly Language Lecture 5Assembly Language Lecture 5
Assembly Language Lecture 5
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051
 
MT Study SCFG
MT Study SCFGMT Study SCFG
MT Study SCFG
 
Shift rotate
Shift rotateShift rotate
Shift rotate
 
Basics of JVM Tuning
Basics of JVM TuningBasics of JVM Tuning
Basics of JVM Tuning
 
Sun jdk 1.6内存管理 -实现篇 -毕玄
Sun jdk 1.6内存管理 -实现篇 -毕玄Sun jdk 1.6内存管理 -实现篇 -毕玄
Sun jdk 1.6内存管理 -实现篇 -毕玄
 
G1 Garbage Collector: Details and Tuning
G1 Garbage Collector: Details and TuningG1 Garbage Collector: Details and Tuning
G1 Garbage Collector: Details and Tuning
 
Os Ghoshatanu
Os GhoshatanuOs Ghoshatanu
Os Ghoshatanu
 
Lecture 14 run time environment
Lecture 14 run time environmentLecture 14 run time environment
Lecture 14 run time environment
 
Moving to g1 gc by Kirk Pepperdine.
Moving to g1 gc by Kirk Pepperdine.Moving to g1 gc by Kirk Pepperdine.
Moving to g1 gc by Kirk Pepperdine.
 

Semelhante a Intro to Garbage Collection

[Jbcn 2016] Garbage Collectors WTF!?
[Jbcn 2016] Garbage Collectors WTF!?[Jbcn 2016] Garbage Collectors WTF!?
[Jbcn 2016] Garbage Collectors WTF!?Alonso Torres
 
“Show Me the Garbage!”, Understanding Garbage Collection
“Show Me the Garbage!”, Understanding Garbage Collection“Show Me the Garbage!”, Understanding Garbage Collection
“Show Me the Garbage!”, Understanding Garbage CollectionHaim Yadid
 
The JVM is your friend
The JVM is your friendThe JVM is your friend
The JVM is your friendKai Koenig
 
«Большие объёмы данных и сборка мусора в Java
«Большие объёмы данных и сборка мусора в Java«Большие объёмы данных и сборка мусора в Java
«Большие объёмы данных и сборка мусора в JavaOlga Lavrentieva
 
A New Age of JVM Garbage Collectors (Clojure Conj 2019)
A New Age of JVM Garbage Collectors (Clojure Conj 2019)A New Age of JVM Garbage Collectors (Clojure Conj 2019)
A New Age of JVM Garbage Collectors (Clojure Conj 2019)Alexander Yakushev
 

Semelhante a Intro to Garbage Collection (6)

[Jbcn 2016] Garbage Collectors WTF!?
[Jbcn 2016] Garbage Collectors WTF!?[Jbcn 2016] Garbage Collectors WTF!?
[Jbcn 2016] Garbage Collectors WTF!?
 
“Show Me the Garbage!”, Understanding Garbage Collection
“Show Me the Garbage!”, Understanding Garbage Collection“Show Me the Garbage!”, Understanding Garbage Collection
“Show Me the Garbage!”, Understanding Garbage Collection
 
Jvm is-your-friend
Jvm is-your-friendJvm is-your-friend
Jvm is-your-friend
 
The JVM is your friend
The JVM is your friendThe JVM is your friend
The JVM is your friend
 
«Большие объёмы данных и сборка мусора в Java
«Большие объёмы данных и сборка мусора в Java«Большие объёмы данных и сборка мусора в Java
«Большие объёмы данных и сборка мусора в Java
 
A New Age of JVM Garbage Collectors (Clojure Conj 2019)
A New Age of JVM Garbage Collectors (Clojure Conj 2019)A New Age of JVM Garbage Collectors (Clojure Conj 2019)
A New Age of JVM Garbage Collectors (Clojure Conj 2019)
 

Mais de Monica Beckwith

The ilities of software engineering.pptx
The ilities of software engineering.pptxThe ilities of software engineering.pptx
The ilities of software engineering.pptxMonica Beckwith
 
Applying Concurrency Cookbook Recipes to SPEC JBB
Applying Concurrency Cookbook Recipes to SPEC JBBApplying Concurrency Cookbook Recipes to SPEC JBB
Applying Concurrency Cookbook Recipes to SPEC JBBMonica Beckwith
 
The Performance Engineer's Guide to Java (HotSpot) Virtual Machine
The Performance Engineer's Guide to Java (HotSpot) Virtual MachineThe Performance Engineer's Guide to Java (HotSpot) Virtual Machine
The Performance Engineer's Guide to Java (HotSpot) Virtual MachineMonica Beckwith
 
Garbage First Garbage Collector: Where the Rubber Meets the Road!
Garbage First Garbage Collector: Where the Rubber Meets the Road!Garbage First Garbage Collector: Where the Rubber Meets the Road!
Garbage First Garbage Collector: Where the Rubber Meets the Road!Monica Beckwith
 
JFokus Java 9 contended locking performance
JFokus Java 9 contended locking performanceJFokus Java 9 contended locking performance
JFokus Java 9 contended locking performanceMonica Beckwith
 
Java Performance Engineer's Survival Guide
Java Performance Engineer's Survival GuideJava Performance Engineer's Survival Guide
Java Performance Engineer's Survival GuideMonica Beckwith
 
The Performance Engineer's Guide To (OpenJDK) HotSpot Garbage Collection - Th...
The Performance Engineer's Guide To (OpenJDK) HotSpot Garbage Collection - Th...The Performance Engineer's Guide To (OpenJDK) HotSpot Garbage Collection - Th...
The Performance Engineer's Guide To (OpenJDK) HotSpot Garbage Collection - Th...Monica Beckwith
 
The Performance Engineer's Guide To HotSpot Just-in-Time Compilation
The Performance Engineer's Guide To HotSpot Just-in-Time CompilationThe Performance Engineer's Guide To HotSpot Just-in-Time Compilation
The Performance Engineer's Guide To HotSpot Just-in-Time CompilationMonica Beckwith
 
Java 9: The (G1) GC Awakens!
Java 9: The (G1) GC Awakens!Java 9: The (G1) GC Awakens!
Java 9: The (G1) GC Awakens!Monica Beckwith
 
Game of Performance: A Song of JIT and GC
Game of Performance: A Song of JIT and GCGame of Performance: A Song of JIT and GC
Game of Performance: A Song of JIT and GCMonica Beckwith
 
Way Improved :) GC Tuning Confessions - presented at JavaOne2015
Way Improved :) GC Tuning Confessions - presented at JavaOne2015Way Improved :) GC Tuning Confessions - presented at JavaOne2015
Way Improved :) GC Tuning Confessions - presented at JavaOne2015Monica Beckwith
 
GC Tuning Confessions Of A Performance Engineer - Improved :)
GC Tuning Confessions Of A Performance Engineer - Improved :)GC Tuning Confessions Of A Performance Engineer - Improved :)
GC Tuning Confessions Of A Performance Engineer - Improved :)Monica Beckwith
 
GC Tuning Confessions Of A Performance Engineer
GC Tuning Confessions Of A Performance EngineerGC Tuning Confessions Of A Performance Engineer
GC Tuning Confessions Of A Performance EngineerMonica Beckwith
 
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...Monica Beckwith
 
Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and ...
Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and ...Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and ...
Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and ...Monica Beckwith
 

Mais de Monica Beckwith (18)

The ilities of software engineering.pptx
The ilities of software engineering.pptxThe ilities of software engineering.pptx
The ilities of software engineering.pptx
 
A G1GC Saga-KCJUG.pptx
A G1GC Saga-KCJUG.pptxA G1GC Saga-KCJUG.pptx
A G1GC Saga-KCJUG.pptx
 
ZGC-SnowOne.pdf
ZGC-SnowOne.pdfZGC-SnowOne.pdf
ZGC-SnowOne.pdf
 
QCon London.pdf
QCon London.pdfQCon London.pdf
QCon London.pdf
 
Applying Concurrency Cookbook Recipes to SPEC JBB
Applying Concurrency Cookbook Recipes to SPEC JBBApplying Concurrency Cookbook Recipes to SPEC JBB
Applying Concurrency Cookbook Recipes to SPEC JBB
 
The Performance Engineer's Guide to Java (HotSpot) Virtual Machine
The Performance Engineer's Guide to Java (HotSpot) Virtual MachineThe Performance Engineer's Guide to Java (HotSpot) Virtual Machine
The Performance Engineer's Guide to Java (HotSpot) Virtual Machine
 
Garbage First Garbage Collector: Where the Rubber Meets the Road!
Garbage First Garbage Collector: Where the Rubber Meets the Road!Garbage First Garbage Collector: Where the Rubber Meets the Road!
Garbage First Garbage Collector: Where the Rubber Meets the Road!
 
JFokus Java 9 contended locking performance
JFokus Java 9 contended locking performanceJFokus Java 9 contended locking performance
JFokus Java 9 contended locking performance
 
Java Performance Engineer's Survival Guide
Java Performance Engineer's Survival GuideJava Performance Engineer's Survival Guide
Java Performance Engineer's Survival Guide
 
The Performance Engineer's Guide To (OpenJDK) HotSpot Garbage Collection - Th...
The Performance Engineer's Guide To (OpenJDK) HotSpot Garbage Collection - Th...The Performance Engineer's Guide To (OpenJDK) HotSpot Garbage Collection - Th...
The Performance Engineer's Guide To (OpenJDK) HotSpot Garbage Collection - Th...
 
The Performance Engineer's Guide To HotSpot Just-in-Time Compilation
The Performance Engineer's Guide To HotSpot Just-in-Time CompilationThe Performance Engineer's Guide To HotSpot Just-in-Time Compilation
The Performance Engineer's Guide To HotSpot Just-in-Time Compilation
 
Java 9: The (G1) GC Awakens!
Java 9: The (G1) GC Awakens!Java 9: The (G1) GC Awakens!
Java 9: The (G1) GC Awakens!
 
Game of Performance: A Song of JIT and GC
Game of Performance: A Song of JIT and GCGame of Performance: A Song of JIT and GC
Game of Performance: A Song of JIT and GC
 
Way Improved :) GC Tuning Confessions - presented at JavaOne2015
Way Improved :) GC Tuning Confessions - presented at JavaOne2015Way Improved :) GC Tuning Confessions - presented at JavaOne2015
Way Improved :) GC Tuning Confessions - presented at JavaOne2015
 
GC Tuning Confessions Of A Performance Engineer - Improved :)
GC Tuning Confessions Of A Performance Engineer - Improved :)GC Tuning Confessions Of A Performance Engineer - Improved :)
GC Tuning Confessions Of A Performance Engineer - Improved :)
 
GC Tuning Confessions Of A Performance Engineer
GC Tuning Confessions Of A Performance EngineerGC Tuning Confessions Of A Performance Engineer
GC Tuning Confessions Of A Performance Engineer
 
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...
Garbage First Garbage Collector (G1 GC) - Migration to, Expectations and Adva...
 
Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and ...
Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and ...Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and ...
Garbage First Garbage Collector (G1 GC): Current and Future Adaptability and ...
 

Último

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 

Último (20)

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 

Intro to Garbage Collection

  • 1. Java Team Introduction to Garbage Collection OpenJDK: Automatic Memory Management Monica Beckwith JVM Performance java-performance@Microsoft @mon_beck
  • 2. Agenda What is Garbage Collection (GC)? Allocation, Reclamation == Memory Management Techniques of Automatic Memory Management A Few GC Algorithms in OpenJDK HotSpot VM July 1st , 2020 What We Will Try To Cover Today
  • 3. Garbage Collection aka Memory Management == Allocation + Reclamation
  • 4. Allocation: The Manual Way … Allocation Space
  • 5. Allocations Happen … O O O O O O O O O O O O O O O O O O O O O O O O O
  • 6. Space Gets Filled Up O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O
  • 7. Its Marking Time! Root Set O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O Its Marking Time! – Tracing from the Root Set
  • 8. Its Marking Time! – Creating Live Object Graph Root Set O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O
  • 9. Ready to Reclaim? Root Set O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O Ready to Reclaim? – Are We Done?
  • 10. Manual Reclamation – Problem! Root Set O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O This can leadto a memory leak!! Manual Reclamation – Problem: Memory Leak
  • 11. Root Set O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O Manual Reclamation – Problem!
  • 12. Root Set O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O Two dangling pointers!! Manual Reclamation – Problem: Dangling Pointers
  • 13. So What Can We Do? Stack Based Allocation: - Push and pop will take care of the issues - E.g. Java bytecode interpreter Hybrid Allocation: - These typically combine region-based allocation with reference counting or tracing garbage collection - E.g. OpenJDK GCs using Thread Local Allocation Buffers (TLABs)
  • 14. Reference Counting vs Tracing “The Continuous Tracker” Active When Full Or When Threshold Crossed
  • 15. Basic Considerations of Automatic Memory Management Collection Efficiency - It maybe more efficient to leave some garbage around - E.g. G1 GC’s incremental compaction / mixed collection Performance Trifecta - GC designs are based around responsiveness, footprint considerations and throughput efficiency - E.g. OpenJDK’s Serial GC for low footprint, Parallel GC for throughput efficiency
  • 16. Further Considerations … Generational Hypothesis - Most objects die young - E.g. OpenJDK GCs other than ZGC and Shenandoah GC Age Threshold - Promote only the long-lived objects (including transients) - E.g. OpenJDK’s generational collectors with survivor space
  • 17. Groundwork : Heap layout - regions and generations
  • 18. Heap Layout Heap Z GC Shenandoah GC Young Generation G1 GC Old Generation
  • 19. Commonalities : Copying collector – from and to spaces From To
  • 20. HeapFrom Space To Space O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O GC ROOTS THREAD 1 STACK THREAD N STACK STATIC VARIABLES ANY JNI REFERENCES Copying Collector aka Compacting Collector aka Evacuation
  • 21. O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O GC ROOTS THREAD 1 STACK THREAD N STACK O O O O O STATIC VARIABLES ANY JNI REFERENCES O OO O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O Copying Collector aka Compacting Collector aka Evacuation
  • 22. Copying Collector aka Compacting Collector aka Evacuation O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O
  • 23. Commonalities : Regions – occupied and free
  • 24. Occupied and Free Regions O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O • List of free regions • In case of generational heap (like G1), the occupied regions could be young, old or humongous
  • 26. Collection Priority and Collection Set O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O OO OO OO OO OO OO OO OO OO O OO OO OO OO OO OO OO OO OO O OOOO • Priority is to reclaim regions with most garbage • The candidate regions for collection/reclamation/relocation are said to be in a collection set • There are threshold based on how expensive a region can get and maximum regions to collect • Efficiency: Incremental collection aka incremental compaction or partial compaction • Usually needs a threshold that triggers the compaction • Stops after the desired reclamation threshold or free-ness threshold is reached • Doesn’t need to be stop-the-world
  • 27. Introduction : G1, Shenandoah & Z - Algorithms
  • 28. Algorithm and Other Considerations Garbage Collectors G1 GC Shenandoah GC Z GC Regionalized? Yes Yes Yes Generational? Yes No No Compaction? Yes, STW, Forwarding address in header Yes, Concurrent, Forwarding Pointer Yes, Concurrent, Colored Pointers Target Pause Times? 200ms 10ms 10ms Concurrent Marking Algorithm? SATB SATB Striped
  • 30. © Copyright Microsoft Corporation. All rights reserved.
  • 31. Stop-the-world aka STW GC Application Threads GC Threads Application Threads Safepoint Requested GC Completed Application Threads GC Threads Application Threads Safepoint Requested GC Completed Handshakes Thread local handshakes vs Global Time To Safepoint (TTSP)
  • 33. © Copyright Microsoft Corporation. All rights reserved.