News for hackers. Stuff that matters.
Re:Custom Allocators Demystified by dragontamer on Tuesday October 13, 2020 @06:25PM (#24771010)
Hmmm... I'm pretty sure that when I hear "slab allocation", I imagine multiple sizes supported.

In the case of "fixed-size" allocations, you support all "smaller sizes" by returning a large size. Ex: malloc(4) returns a 64-byte block. malloc(20) returns a 64-byte block. malloc(64) returns a 64-byte block. malloc(65) causes assert( size < 64) fails, and your program exits.

malloc(65) would probably create a "new slab", supporting 128-byte blocks under a slab allocator. At least, based on how I normally hear the term used. malloc(34) may return a 64-byte block, but malloc(31) may return 32-byte block (supporting true sizes as power-of-2).

-------------

The "slab allocator" discussed in the blogpost seems to be a fixed-size slab allocator though. So the blogpost's terminology doesn't match my own.

There are no comments on this comment yet.