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
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
0
490
TerraformとStrands AgentsでAmazon Bedrock AgentCoreのSSO認証付きエージェントを量産しよう!
neruneruo
4
2.4k
AtCoder Conference 2025
shindannin
0
930
[AtCoder Conference 2025] LLMを使った業務AHCの上⼿な解き⽅
terryu16
6
1k
20251212 AI 時代的 Legacy Code 營救術 2025 WebConf
mouson
0
250
クラウドに依存しないS3を使った開発術
simesaba80
0
220
ThorVG Viewer In VS Code
nors
0
670
それ、本当に安全? ファイルアップロードで見落としがちなセキュリティリスクと対策
penpeen
7
2.1k
AI 駆動開発ライフサイクル(AI-DLC):ソフトウェアエンジニアリングの再構築 / AI-DLC Introduction
kanamasa
11
5.3k
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
110
AI Agent Tool のためのバックエンドアーキテクチャを考える #encraft
izumin5210
6
1.6k
Giselleで作るAI QAアシスタント 〜 Pull Requestレビューに継続的QAを
codenote
0
340
Featured
See All Featured
30 Presentation Tips
portentint
PRO
1
190
Evolving SEO for Evolving Search Engines
ryanjones
0
98
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
39
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.8k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
360
Building the Perfect Custom Keyboard
takai
2
670
Making the Leap to Tech Lead
cromwellryan
135
9.7k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
0
120
GraphQLとの向き合い方2022年版
quramy
50
14k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
420
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
78
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