This is a custom memory allocator I wrote in C. Its features are:
-
Lack of loops, where every memory-related code path is
O(1)
. -
Lack of per-allocation metadata, increasing cache friendliness and decreasing memory footprint.
-
All allocations are by default aligned to the next or equal power of 2 of the size that is requested. 1
-
Thread-safe by default, with an option to disable it at compilation.
-
Decentralized, allowing for scalability and fragmentation resistance.
-
Simpler, faster, using less kernel time than all dlmalloc offsprings. 2
-
Completely encapsulated, with zero heap usage.
-
Customizable at compile-time (the defaults) as well as at runtime.
It supports Linux, MacOS, Windows (mingw/msys), 64bit and 32bit.
See this for more information.
See this for more information.
By design (no heap usage), WebAssembly is not and never will be supported.
... are welcome. This is a very fresh, immature projects. It could use more updates.
Footnotes
-
Zero cost for small allocations, then grows slightly as the allocation size grows, caps out at below a page size for large allocations (not per-allocation, but per-handle), which comparatively is rather little. ↩
-
33-50% faster on Linux/MacOS, ~75% faster on Windows, but speed may vary between different environments and workloads. The kernel time difference used to be clearly visible back when
time
was used to measure the benchmark, but there have been issues with the command not working on some platforms in specific settings, so it was replaced with in-code time measuring that only takes real time into account. ↩