3 ms·
What is "low-fragmentation heap"? Why would anyone want "high-fragmentation heap"? (since you imply that it's an option)
by orijing 14y ago
What is "low-fragmentation heap"? Why would anyone want "high-fragmentation heap"? (since you imply that it's an option)
- cperciva 14y agoWhy 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).
- cpeterso 14y agoMicrosoft Low-fragmentation Heap: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366750%28v=vs.85%29.aspx http://msdn.microsoft.com/en-us/library/windows/desktop/aa36...
- vl 14y agoLow-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.