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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
KIKI_MBSD Cybersecurity Challenges 2025
ikema
0
1.3k
Smart Handoff/Pickup ガイド - Claude Code セッション管理
yukiigarashi
0
150
AI & Enginnering
codelynx
0
120
React 19でつくる「気持ちいいUI」- 楽観的UIのすすめ
himorishige
11
7.5k
Data-Centric Kaggle
isax1015
2
780
AI によるインシデント初動調査の自動化を行う AI インシデントコマンダーを作った話
azukiazusa1
1
750
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
1
990
Raku Raku Notion 20260128
hareyakayuruyaka
0
360
AIによる開発の民主化を支える コンテキスト管理のこれまでとこれから
mulyu
3
470
dchart: charts from deck markup
ajstarks
3
1k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
610
CSC307 Lecture 05
javiergs
PRO
0
500
Featured
See All Featured
Facilitating Awesome Meetings
lara
57
6.8k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.1k
A Modern Web Designer's Workflow
chriscoyier
698
190k
GraphQLの誤解/rethinking-graphql
sonatard
74
11k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
920
Navigating Weather and Climate Data
rabernat
0
110
How to Ace a Technical Interview
jacobian
281
24k
Typedesign – Prime Four
hannesfritz
42
3k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
740
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
79
Into the Great Unknown - MozCon
thekraken
40
2.3k
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