As if there were not enough dynamic memory allocators floating around, I had to write my own one. Of course, I didn't start from scratch, but tried come up with an implementation of Maged M. Michael's Scalable Lock-Free Dynamic Memory Allocator.

Due to the need for a lock based allocator, I added a simplified variant which uses plain locking instead of atomic operations. The lock-free variant also features an implementation of hazard pointers, as described by the very same author referenced above. Otherwise the two variants are very similary.


The allocator, as provided here, certainly isn't a drop-in replacement. It is more a proof-of-concept and could certainly use some cleanup. It comes with its own, trivial exerciser (AKA yet another micro-benchmark) and there's lots of duplicate code between the two variants.

Source Code

License: Boost Software License 1.0 (BSD like)