Question

I've written a c/c++ memory manager for heap allocations (overloaded new/delete and malloc/realloc/free, based on Doug Lea's malloc but designed to be wait free) and seem to be having some trouble with fragmentation. Are there any good resources out there that detail good strategies for avoiding fragmentation via the manager?

Please note that I can't rearrange memory that has already been allocated (not using smart pointers with GUIDs) and re-writing the system to use pools instead of heap allocations is unfeasible.

Thanks,
Grant

Was it helpful?

Solution

You may want to get some inspiration from jemalloc (http://people.freebsd.org/~jasone/jemalloc/bsdcan2006/jemalloc.pdf) - this allocator is used in the new Firefox explicitly because of its anti-fragmentation capabilities.

OTHER TIPS

Have a look at how more mature projects like glibc do it.

A quick Google finds this, with a stack of references.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top