Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/suirad/adma
A general purpose, multithreaded capable slab allocator for Zig
https://github.com/suirad/adma
allocator general-purpose slab-allocator zig zig-lang zig-library
Last synced: about 2 months ago
JSON representation
A general purpose, multithreaded capable slab allocator for Zig
- Host: GitHub
- URL: https://github.com/suirad/adma
- Owner: suirad
- License: mit
- Created: 2020-06-17T04:11:37.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-01-27T06:31:44.000Z (almost 4 years ago)
- Last Synced: 2024-10-01T03:22:55.533Z (2 months ago)
- Topics: allocator, general-purpose, slab-allocator, zig, zig-lang, zig-library
- Language: Zig
- Size: 20.5 KB
- Stars: 54
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-zig - suirad/adma
- awesome-zig - adma🗒️A general purpose, multithreaded capable slab allocator for Zig
README
# A.D.M.A - Acronyms Dont Mean Anything
Adma is a general purpose allocator for zig with the following features:
- [x] [Slab Allocation strategy](https://en.wikipedia.org/wiki/Slab_allocation)
- [x] Optimized for rapid small memory allocation/releasing
- [x] Reuse of OS provided allocations
- [x] Non-Blocking allocation & free within a thread
- [x] Multithreaded Capable
- [x] Automatic feature reduction for single threaded use
- [x] Safe freeing of memory sent to a different thread## Getting started
In Zig:
```zig
const adma = @Import("adma");pub fn example() !void {
// .initWith using a c allocator
//const adma_ref = try adma.AdmaAllocator.initWith(std.heap.c_allocator, 0);// .init defaults to using std.heap.page_allocator underneath for ease of use
const adma_ref = adma.AdmaAllocator.init();
defer adma_ref.deinit();const allocator = &adma_ref.allocator;
var buf = try allocator.alloc(u8, 100);
defer allocator.free(buf);
}```
## Usage Notes
- If using adma in a multithreaded context, ensure you `AdmaAllocator.init/deinit`
in every thread; not pass the allocator pointer to the additional thread
- If using for zig prior to the big allocation interface change, see the branch
called `pre-allocator-revamp`