Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Understanding Garbage Collection Through Visual...
Search
Andrew Gwozdziewycz
May 18, 2014
Programming
180
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Understanding Garbage Collection Through Visualizing a One Pass Real-Time Generational Mark-Sweep Garbage Collector!
#bangbangcon
Andrew Gwozdziewycz
May 18, 2014
More Decks by Andrew Gwozdziewycz
See All by Andrew Gwozdziewycz
wipes.pdf
apg
0
44
Other Decks in Programming
See All in Programming
contenteditable と日本語入力に向き合う
colorful12
0
200
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
380
月間100万人のサービス刷新で、 技術選定をHonoに振り切った話
yutobara
8
6.7k
Workers Cache を知る
syumai
0
370
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
1.2k
残高管理から台帳サービスへの進化
artoy
1
200
RAG の “R” を Swift で覗いてみる 〜「意味から探す」検索の仕組み〜
nao_randd
0
160
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
7
13k
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
2
760
Performance Optimization With LLMs
xleitix
0
110
コーディング自動化の次へ。人の介入をゼロにするファクトリーとサポートAIによる実践
timakin
5
3.8k
外から家のPCの電源入れたい!をPHPで解決する
kawashimo0
1
140
Featured
See All Featured
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
740
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.4k
Six Lessons from altMBA
skipperchong
29
4.5k
Designing Experiences People Love
moore
143
24k
The SEO identity crisis: Don't let AI make you average
varn
0
590
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
480
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
270
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
410
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
570
Mobile First: as difficult as doing things right
swwweet
225
10k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
710
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