Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Modern heaps typically have some low-fragmentation technique built-in, for example, Windows ships with Low Fragmentation Heap, which is turned on by default since Vista.


What is "low-fragmentation heap"? Why would anyone want "high-fragmentation heap"? (since you imply that it's an option)


Low-fragmentation heap puts object of similar size together, so once object is freed, this memory can be reused for other object of similar size without fragmentation. Because of this is has more "slack" - unused memory at the end of the objects that are smaller than their buckets. On other hand, application in steady state is not going slowly increase it's memory use over time.

Also it puts consequently allocated objects (of different size) far away (and thus reduces cache locality), which, in turn may reduce performance for some "allocate a lot of stuff at the beginning and then serve it", etc scenarios, but this is pretty esoteric problem.

Benefits outweigh the concerns, so most apps benefit from the low-fragmentation heaps.


Why would anyone want "high-fragmentation heap"?

For short-lived processes, it's faster and uses less memory. The code is also simpler (important if you're writing a malloc in the mid-1980s).





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: