Storage leak:
Allocating a block, then forgetting to free it
eventually the heap is full of garbage,
further allocations fail,
and the program crashes
Dangling pointer:
Freeing a block while active pointers
are still pointing to it
if the block is reallocated,
it can get corrupted
if referenced from an obsolete pointer
The defect shows up far away from
where it actually happened
The defect shows up much later than
when it actually happened
Exceedingly difficult to debug
It improves abstraction and modularity
A class need not include code
to deal with an unrelated issue
(storage deallocation)
A classs interface
need not include storage-related operations
Some languages require garbage collection
Java!
For this lecture we will take garbage collection to be a given