



















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!




















Garbage Collection
Major Areas of Memory
Heap Storage Deallocation Examples:
Cells and Liveness
Dangling References
Example of Garbage class node { int value; node next; } node p, q; p = new node(); q = new node(); q = p; delete p;
Garbage Collection − (^) Advantages: implementation simplicity, speed − (^) Disadvantages: burden on programmer, may produce garbage (memory leaks or dangling references)
Garbage collection (^) Essential for functional languages - frequent construction and return of objects from functions (^) Increasingly used in imperative languages (Ada, Java) (^) Mechanisms: (^) Reference Counter (^) Mark-and-Sweep
01 0 0 0 Reference Counting Example 1 2 1 1 root set Heap space
2 1 1 1 Reference Counting Example 0 1 root set Heap space
2 1 1 1 Reference Counting Example 0 0 0 1 1 Returned to free list root set Heap space
Reference Counts
slide 20 root set Heap space