$linuxjunkies
>

slab allocator

also: slab cache, SLUB, slab memory allocator

The slab allocator is a kernel memory management subsystem that efficiently allocates and caches small objects of fixed sizes, reducing fragmentation and allocation overhead.

The slab allocator divides memory into slabs—contiguous regions containing multiple objects of the same type and size. Each slab holds many identical objects, so when the kernel needs memory for common structures (like file descriptors or network buffers), it pulls from a pre-allocated cache rather than requesting memory from the page allocator each time.

This approach dramatically reduces fragmentation and speeds up allocation, since the kernel avoids the overhead of frequent large allocations and can reuse memory layouts. For example, if the kernel constantly creates and destroys file descriptor structures, the slab allocator keeps a pool of them ready to use, dramatically faster than allocating and freeing individual pages.

You can inspect slab usage on your system by reading /proc/slabinfo, which shows each slab cache, the number of active objects, and memory consumption. Modern Linux kernels also support SLUB (Unqueued Slab Allocator), a simpler variant optimized for modern multi-core systems.

Related terms