Defragmenter

free = starting location of new heap;
for (each object o in heap) {
		if (o is not freed) {
				NewLocation(o) = free;
				free = free + size(o);
		}
}
for (each object o in heap) {
		if (o is not freed) {
				for (each reference o.r in o) {
						o.r = NewLocation(o.r);
				}
				copy o to NewLocation(r);
		}
}
// add this to the above implementation
for (each reference r in the root set) {
		r = NewLocation(r);
}
delete NewLocation map.

Automatic memory management

finding free objects

Untitled