How does heap compaction work quickly?

Posted by Mason Wheeler on Stack Overflow See other posts from Stack Overflow or by Mason Wheeler
Published on 2010-04-18T18:04:49Z Indexed on 2010/04/18 18:13 UTC
Read the original article Hit count: 492

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 NP-hard 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?

© Stack Overflow or respective owner

Related posts about algorithms

Related posts about garbage-collection