The document discusses garbage collection techniques used in Android, including mark-and-sweep, generational, and copying collection. It covers the goals of memory management in Android including minimizing app launch time and disk space usage. Key garbage collection algorithms described are mark-and-sweep, Cheney's copying algorithm, and concurrent mark-sweep.
1. GARBAGE COLLECTION IN ANDROID VIKAS M.Tech(Digital Comm) MSRIT, Bangalore
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12. TWO FINGER ALGORITHM FOR MARK AND SWEEP GARBAGE COLLECTION FLOWCHART There are two ptrs Free_ptr and Live_ptr void mark (Object p) if (!p.marked) p.marked = true; for each Object q referenced by p mark (q); void sweep () for each Object p in the heap if (p.marked) p.marked = false else heap.release (p);
14. Generational Garbage collection avoids repeated collection of objects by dividing the heap into old and young generations. • Separate young objects • Monitor references to young from old – “ Remembered Set” • Use those as roots to collect just the young space (II) Generational Garbage collection
25. Pinned objects are promoted at the start of a garbage collection so that they are not moved to next space
26.
27. After the stack and registers are searched and promoting is done, the garbage collector scans the objects inside them. Scanning is done using a breadth-first discipline