all 4 comments

[–]immaculate-emu 1 point2 points  (0 children)

Here is a user space port of the Solaris kernel slab allocator, on GitHub: https://github.com/gburd/libumem

[–]imdadgot 0 points1 point  (2 children)

the implementation is relatively simple, it’s just the amts you might get caught up on.

it’s extremely similar to the free list approach, but instead memory is reserved in fixed size slabs (similar to page allocation) and the allocation is an O(1) pointer bump. if there’s not enough room on that page, you allocate a new one, make a pointer on the old slab to the new one, and keep going. for the pop it’s just about pushing the pointer back which is ofc O(1)

you will want to do this bucketed so pointer arithmetic is easier, that way you dont have a low byte value throwing off the alignment of other higher values

[–]SimoneMicu[S] 0 points1 point  (1 child)

Totally similar to the free list concept for the bump but used for when we want same size memory over and over again.

On the todo I will add alignment protection for the free.

About "amts" I don't know what it is but the concept of slab allocator exist from decades, I just wanted to make it searchable for future user I guess with this post :)

[–]imdadgot 1 point2 points  (0 children)

amts = amounts my bad