Allocators, fragmentation and OOM Live objects fall but RSS stays high An image worker throws away nearly every temporary object from a batch. The heap inspector agrees. The machine still reports a large resident footprint. Eli asks what else is sharing the pages that survived. After equivalent batches the older worker sat at a hundred eighty mebibytes resident. The changed worker sits at four hundred ten. A tiny surviving object can keep a page containing mostly freed slots mapped and resident. An allocator subdivides pages into objects and retains free space for reuse. An application can release most objects while one live allocation pins each of many pages. Application heap in context The heap then contains substantial free space but has few whole pages available to return. Virtual reservation, committed memory, resident memory and live object size answer different questions. Internal fragmentation wastes space within allocated units. External fragmentation leaves enough total free memory in pieces too small or poorly placed for the required allocation. Compaction moves movable pages to create larger contiguous ranges. Allocation can therefore incur latency even when the total free page count looks adequate. Overcommit permits promises of virtual memory beyond immediately available backing under some policies. First touch and later memory pressure can expose costs absent at reservation time. A worker allocates ten equally sized objects, then frees nine. The remaining object can pin the allocator's backing page even though application accounting calls most of the space free. On the next batch, those free slots may serve new objects without asking the kernel for additional pages. Follow live objects down to pages A contiguous free region supplies objects of several sizes and lifetimes. Surviving allocations divide the free space into holes. Three independent hundred-byte holes cannot satisfy one contiguous two-hundred-byte request in this model. A hundred-byte object in a hundred-and-twenty-eight-byte class instead leaves twenty eight bytes inside its own allocation. Distinguish a reservation from a committed physical page in a second experiment. An application can reserve a large virtual range and touch only a small part of it. Virtual size may jump without a matching resident increase. Touching the remainder can change physical demand later. Measure the point where the workload actually writes or reads each area before interpreting a chart as a runaway allocator. Read the measurements Repeat equal-sized batches with high and low concurrency. A stable high-water mark can reflect retained arenas. A growing count of live objects after equivalent batches suggests that references remain reachable. Compare allocation profiles and object ownership with resident memory through several cycles. One snapshot cannot distinguish the two. If resident memory increases from one hundred eighty to four hundred ten binary megabytes after a batch, do not immediately label the difference leaked bytes. Break the reading into private anonymous memory, file-backed memory and shared mappings. Compare the live-object count at the same point in each batch cycle. Retained objects or allocator slack? Which observation would make an ordinary object leak less convincing? Compare live objects grouped by owner with allocated arenas after the same workload and collection point. A stable live inventory with more unused space between survivors points toward fragmentation or allocator caching. Check both before raising a limit. A growing reachable object graph after equivalent batches calls for object lifetime analysis before allocator tuning. Check the competing explanation Kernel slab caches reuse storage for frequently allocated object types. Slab growth can consume substantial memory outside an application heap, so inspect the responsible object class. Userspace allocators use size classes, arenas and thread caches to reduce contention. Retention policy influences resident memory after load falls even when application objects are freed. A pool reuses preallocated storage. A per-request arena can release many objects together, but a single long-lived reference can extend the lifetime of all allocations in that arena. Repeat several batches before resizing Grouping similar lifetimes brings the example down to two hundred five of the same binary units resident. A stack frame usually lives for a call’s duration. Heap objects have independent lifetimes governed by an allocator or garbage collector. Lifetime and ownership determine retention. Eli also measures allocation latency. Returning pages sooner can trade a smaller footprint for extra work on the next batch. Apply the diagnosis If a worker restarts and resident memory falls, both a leak and reusable allocator capacity predict that observation. Ask the stronger question. After the application reaches its normal steady load again, does the old slope return? Track user-facing latency too, because aggressively returning memory may trade resident size for more work on the next allocation.