solution to fragmentation. Well okay, but what’s wrong with fragmentation? What is compaction solving?
The most obvious problem is that a fragmented heap will take up more overall memory than a compacted heap. If we look again at our extreme example from above, all of those
RVALUES could have fit into just one page, instead of five. Like most things, memory can be a limited resource, so obviously it’s beneficial to utilize it efficiently.
But it turns out there are other reasons to compact, too. Let’s discuss some of them!
CPU Cache Hits
The OS usually loads small chunks of memory into a cache which is quicker to access than the rest of memory. It will take less time to acess an