Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Understanding Garbage Collection Through Visual...
Search
Andrew Gwozdziewycz
May 18, 2014
Programming
0
170
Understanding Garbage Collection Through Visualizing a One Pass Real-Time Generational Mark-Sweep Garbage Collector!
#bangbangcon
Andrew Gwozdziewycz
May 18, 2014
Tweet
Share
More Decks by Andrew Gwozdziewycz
See All by Andrew Gwozdziewycz
wipes.pdf
apg
0
37
Other Decks in Programming
See All in Programming
なるべく楽してバックエンドに型をつけたい!(楽とは言ってない)
hibiki_cube
0
140
Honoを使ったリモートMCPサーバでAIツールとの連携を加速させる!
tosuri13
1
180
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
440
AgentCoreとHuman in the Loop
har1101
5
240
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
390
dchart: charts from deck markup
ajstarks
3
1k
CSC307 Lecture 03
javiergs
PRO
1
490
KIKI_MBSD Cybersecurity Challenges 2025
ikema
0
1.3k
humanlayerのブログから学ぶ、良いCLAUDE.mdの書き方
tsukamoto1783
0
200
360° Signals in Angular: Signal Forms with SignalStore & Resources @ngLondon 01/2026
manfredsteyer
PRO
0
130
ぼくの開発環境2026
yuzneri
0
240
CSC307 Lecture 04
javiergs
PRO
0
660
Featured
See All Featured
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
100
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
52
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
350
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
SEO for Brand Visibility & Recognition
aleyda
0
4.2k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
67
Discover your Explorer Soul
emna__ayadi
2
1.1k
A Modern Web Designer's Workflow
chriscoyier
698
190k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Believing is Seeing
oripsolob
1
58
Designing for Timeless Needs
cassininazir
0
130
Transcript
Understanding Garbage Collection Through Visualizing a One Pass Real- Time
Generational Mark-Sweep Garbage Collector! Andrew Gwozdziewycz (Guh-shev-itz) http://apgwoz.com !!Con, 2014
Free the mallocs
Manual Memory Management is Difficult
Acquire. Process. Release.
Naive Mark-Sweep
Mark sweep: Roots management, marking Marked
Mark sweep: Sweep Iterate over MEM. Free unmarked items.
I saw this wino, he was eating grapes. I was
like, “Dude, you have to wait.” -- MItch Hedberg
How can we make this better?
Idea: Combine the mark and sweep phase. (One pass)
Idea: Shorter pauses by doing less work more often. (Incremental)
Idea: Shorter pauses by doing less work more often. (Real-
time)
Idea: "Most objects die young." Separate the heap into old
and new. (Generational)
Yes We Can!
One Pass Real-Time Generational Mark-Sweep Garbage Collection Joe Armstrong, Robert
Virding, 1995
def mark_all(): SCAV = most_recent_alloc while SCAV > min_heap_addr: if
marked(SCAV): mark_pointers(SCAV) SCAV -= 1 SCAV min_heap_addr
def alloc(): obj = new() obj.previous =\ most_recent_alloc most_recent_alloc =
obj return obj obj most_recent_alloc
def gc(): last_alloc = most_recent_alloc SCAV = last_alloc.previous while SCAV
!= first_alloc: if marked(SCAV): mark_pointers(SCAV) unmark(SCAV) last_alloc = SCAV SCAV = last_alloc.previous else: tmp = SCAV SCAV = SCAV.previous last_alloc.previous = SCAV free(tmp) tmp last_alloc new SCAV
BUT WAIT THERE’S MORE!!!!11
This is incremental!
This is generational!
But, is it practical?
Advantages 1. Shear Simplicity 2. Ease of extension 3. Objects
get reused quickly
But, 303 See Other
Thanks! https://github.com/apg/bangbangcon http://apgwoz.com @apgwoz
Image Resources 1. "Spread the Gnus": https://secure.flickr. com/photos/puliarfanita/6026330732/in/photolist-abwwb1-6ApYxu-jEp8pV-c2eXqw-81LPL-wjjkT-4JZqBQ- 6o3mJG-9YRiUm-3t4km-Ahtjx-9YNqoc-pZvNx-7mis1-czaJeS-czaHES-aUfdNe-6UaPSX-693pNg-fb84D-3QZoJ5- 5gm73-5ugFB8-73u9hq-aB4ivt-PUDs-a1xmWo-c2h9qG-73riU-7dUFU7-f9n7iJ-Kmwk6-4H614e-6gmUKL-5QUPxX-
mXKrB-mG5w-aZ9cUz-LV31W-acH9dy-JYgvQ-JYfUN-ER1PN-evG5H-8UAthy-PkV7c-7JFKr1-4vUig4-7afj6F-8V1EY6 2. “Billy Mays”: https://upload.wikimedia. org/wikipedia/commons/f/fa/Billy_Mays_Portrait_Cropped.jpg