Skip to content

supahero1/alloc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a custom memory allocator I wrote in C. Its features are:

  1. Lack of loops, where every memory-related code path is O(1).

  2. Lack of per-allocation metadata, increasing cache friendliness and decreasing memory footprint.

  3. All allocations are by default aligned to the next or equal power of 2 of the size that is requested. 1

  4. Thread-safe by default, with an option to disable it at compilation.

  5. Decentralized, allowing for scalability and fragmentation resistance.

  6. Simpler, faster, using less kernel time than all dlmalloc offsprings. 2

  7. Completely encapsulated, with zero heap usage.

  8. Customizable at compile-time (the defaults) as well as at runtime.

It supports Linux, MacOS, Windows (mingw/msys), 64bit and 32bit.

C

See this for more information.

Rust

See this for more information.

WebAssembly

By design (no heap usage), WebAssembly is not and never will be supported.

Contributions

... are welcome. This is a very fresh, immature project. It could use more updates.

Footnotes

  1. 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.

  2. 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.

About

Highly space and performance efficient C allocator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published