


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



3 Algorithmic Components of Garbage Collection - ANS1. Allocation 2. Identification 3. Reclamation Allocation (2 types) - ANSfree list, bump allocation (same as explicit memory management) Challenges of identifying garbage - ANShard and expensive Time proportional to dead objects or live objects depends on method collecting less frequently reduces total time but increases space requirements and pause times (space/time tradeoff) Common Heap Concerns - ANSlocality fragmentation paging (use space better) time/space tradeoff Evaluating Garbage Collection Algorithms - ANS1. Space efficiency (fragmentation and metadata) 2. Efficiency of allocator (time to allocate, locality of contemporaneously allocated objects) 3. Time to collect garbage (fast? incremental reclamation? Generational Heap Organization - ANSDivide heap, from space, into two spaces: young and old Allocate into young space when young space fills up, collect it, copy into the old space. when old space fills up, collect both spaces (into tospace) Generational hypothesis - ANSYoung objects die more quickly than older ones Takeaway: organize heap into young
and old, collect young objects preferentially Identification - ANSTracing / implicit -- traces program pointers to determine what is reachable Reference counting / explicit -- Program keeps track of how many objects use a pointer Mark-Compact Performance - ANSFast Allocator Space Efficient Good locality Garbage Collection: expensive, requires 2 traversals, slower than mark-sweep overall. Total performance is worse than mark-sweep Mark-Compact, how does it work? - ANSbump allocation, trace, compact - keep smushing objects together 1. find reachable objects + sweeping for unreachable blocks, c 2. copy all objects remaining in the heap to one end of the heap. Mark-Sweep Performance - ANSSpace Efficient Incremental object reclamation BAD slower allocation time b/c of free list BAD locality of contemporaneously allocated objects Garbage Collection: simple, very fast Mark-Sweep, how does it work? - ANSfree-list, trace, sweep-to-free - binning for free list / to make it less time consuming to allocate, because most objects are small - allocation: free-list - no memory of right size triggers collection - Mark Phase: find reachable objects, tracing and transitive closure - Sweep Phase: sweep memory for unreachable blocks on the free list. Could be incremental by organizing heap into blocks and sweeping one block at a time on demand. pause time - ANStime the program is paused from doing work while garbage is collected Reclamation - ANStaking
"sweep" unreachable objects 4. wait for garbage collection algorithm to be run again transitive closure - ANSadding to the set until you can't anymore. In tracing, keep following things that one object points to until there are no more VM principles applied to heap memory management - ANSprograms have locality internal vs. external fragmentation keep pagining to a minimum What is a safe pointer? Why do we have them? - ANSautomatic garbage collectors use these (ex. Java) programs cannot access arbitrary addresses in memory compiler can identify and provide garbage collector all pointers runtime system moves objects by updating pointers What is garbage? - ANStheory: dead objects, never accessed again, unidentifiable by system or compiler practice: unreachable objects, any object program can't reach, identifiable who manages the heap? - ANSthe runtime environment