Wednesday, May 12, 2010

How malloc Works on the Mac

Matt Gallagher:

The reason for separate regions for tiny and small allocations is that it allows the region’s metadata to be more efficiently tuned to tracking the size of object it contains. For “tiny” allocations, tracking memory down to 16 byte units is worthwhile (it allows freed space to be reclaimed better and doesn’t waste large amounts of memory around allocated objects). For “small” sized objects though, tracking at this resolution would be a poor tradeoff between CPU time (traversing through lists of freed or allocated blocks) and memory efficiency—the coarser 512 byte resolution is more efficient.

Comments RSS · Twitter

Leave a Comment