Slab Allocation — Kernel Object Caches
Slab allocation organizes kernel memory for frequently allocated objects, typically through size classes and dedicated caches. SLUB is a common Linux implementation. Reusing objects and grouping allocations can reduce overhead and fragmentation; allocator behavior depends on kernel configuration and workload. Slab memory is different from an application's heap or cached file contents. /proc/meminfo reports aggregate slab accounting, including reclaimable and unreclaimable portions. Reclaimable does not mean all bytes can be reclaimed immediately. A growing cache may be normal under load or indicate a problem; compare time series and object-level evidence where authorized rather than labeling any large value a leak. /proc/slabinfo and detailed sysfs slab attributes may be restricted. The example parses three aggregate fields without requiring privileged access or changing allocator settings. It does not test allocator internals. Example prerequisites: Linux, Bash and Python 3 standard library; run as a non-root user in a private temporary working directory. Example scope: native read-only observation. Expected output: slab accounting counters parsed (kB). No system configuration changes.
Formal Syntax & Structure
/proc/meminfo: Slab, SReclaimable, SUnreclaimParameters & Attributes
| Name | Type | Description |
|---|---|---|
| Slab | kB counter | Aggregate slab memory. |
| SReclaimable | kB counter | Slab memory potentially reclaimable. |
| SUnreclaim | kB counter | Slab memory not reclaimable through ordinary slab reclaim. |
Return Value
A dynamic accounting snapshot, not a leak detector; example validates field formats.
Working Example
python3 - <<'PY'from pathlib import Pathrows=dict(line.split(':',1) for line in Path('/proc/meminfo').read_text().splitlines())for name in ('Slab','SReclaimable','SUnreclaim'): value,unit=rows[name].split() assert int(value)>=0 and unit=='kB'print('slab accounting counters parsed (kB)')PY