Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Understanding Garbage Collection Through Visual...

Understanding Garbage Collection Through Visualizing a One Pass Real-Time Generational Mark-Sweep Garbage Collector!

#bangbangcon

Avatar for Andrew Gwozdziewycz

Andrew Gwozdziewycz

May 18, 2014
Tweet

More Decks by Andrew Gwozdziewycz

Other Decks in Programming

Transcript

  1. 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
  2. I saw this wino, he was eating grapes. I was

    like, “Dude, you have to wait.” -- MItch Hedberg
  3. def mark_all(): SCAV = most_recent_alloc while SCAV > min_heap_addr: if

    marked(SCAV): mark_pointers(SCAV) SCAV -= 1 SCAV min_heap_addr
  4. 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