inaccessible memory
data that can have no use to the program but still takes up memory
manual memory management
no garbage collector, the programmer must manually allocate and deallocate memory
use after free
overwrites data used somewhere else
double free
more than one free in different places
invalid free
passing a non-malloced pointer to free
not checking for allocation fail
always check malloc != 0
memory leak
not freeing data after use
reading uninited memory
security attack vector
dangling pointers
pointers to freed memory
probabilistic memory safety: replacement MM
probabilistic memory safety: replicated mode
execute multiple copies concurrently, high chance correct programs output same values
different random seeds for allocators
garbage collection properties
reference counting
keep count of the number of pointers to an object, when reference count == 0 add object to free list
reference counting pros
reference counting cons
mark+sweep
mark all live data, sweep to collect inactive data
associate a mark with each active heap object via depth-first, in-place traversal
mark+sweep pros
mark+sweep cons
mark+sweep+compact
uses mark+sweep and then makes all live data contiguous
copies data breadth first, uses forwarding pointers
forwarding pointer
when data is moved a forwarding pointer is placed at the old location which stores the datas new position
2-space copy
memory is in two equal regions, FROM and TO
data is allocated in FROM, when FROM fills active data is copied to TO and they are swapped
2-space copy pros
2-space copy cons
wastes memory