title: How does heap compaction work quickly?
body: <p>They say that compacting garbage collectors are faster than traditional memory management because they only have to collect live objects, and by rearranging them in memory so everything's in one contiguous block, you end up with no heap fragmentation.  But how can that be done quickly?  It seems to me that that's equivalent to the bin-packing problem, which is <a href="http://en.wikipedia.org/wiki/NP-hard" rel="noreferrer">NP-hard</a> and can't be completed in a reasonable amount of time on a large dataset within the current limits of our knowledge about computation.  What am I missing?</p>