Investigating retained memory A cache that never releases old tenants A tenant has left the service. Its data still has an owner inside the worker. Ana looks at the lowest heap measurement after each collection, since the peak during an active batch can rise for completely legitimate reasons. Under comparable load the post-collection live heap rises from ninety-five to three hundred sixty mebibytes. At the same time the cache still lists tenants that have gone inactive. The pattern points to retained references worth inspecting. A memory leak in a managed service can consist entirely of reachable objects that are no longer useful. A rising high-water mark alone is ambiguous because workload growth, allocator retention and filesystem cache can all influence RSS. Request handler in context A tenant leaves the service, yet a map still holds its session object. The garbage collector treats that reference as live and correctly retains it. Looking only at allocation rate can be misleading because a healthy worker may allocate many short-lived objects and then collect them all. Follow the owner across collections Measure the live set after comparable collections at equal workload and compare the objects retaining it. A worker caches data per tenant and never evicts inactive entries. Capture two bounded heap summaries under similar load and group by retained size and owner. A rising post-collection floor with a growing key count supports the cache hypothesis. Use expiry or a size bound consistent with correctness and test churn over several collection cycles. Try to falsify the stale-tenant hypothesis. Insert and remove one test tenant, drop the known application reference, then inspect whether the same tenant identifier remains reachable after the normal expiry and collection conditions. If it disappears but the process stays large, investigate a different ownership path or allocator retention. The test connects one lifecycle event to one object instead of inferring a leak solely from a graph. Read the measurements Start two identical batches with the same number of tenants and the same request mix. Let each end, then compare live objects at equivalent collection points. Find a surviving object and follow the path that keeps it reachable. Repeated growth in stale tenant objects is stronger evidence than a process size which rose once and plateaued. Imagine a worker which caches the most recent hundred tenants but receives ten new tenants per hour. Growth during the first ten hours fits the stated policy. If the owner map then grows to two hundred tenants and includes inactive identifiers, measure where eviction was supposed to happen and which references survived it. Test retention under tenant churn Would high resident memory alone prove that this cache owns a growing number of live objects? Resident pages can stay high after objects die. Compare retained size by owner and the number of inactive keys across two bounded summaries. A cache problem predicts surviving objects reachable from that cache. If the live set stays flat, investigate native buffers, allocator retention, mapped files and file cache before calling it a managed-heap leak. Check the competing explanation Keep separate traces for allocated bytes per second, live bytes after equivalent collections, and resident memory. A process can allocate at a high rate and free successfully, or slowly retain a small amount forever. The slope of the retained population under comparable demand answers a different question from peak allocation throughput. A leak can also live outside a managed heap. A process may retain native buffers, open descriptors or allocation mappings. If the managed heap stays flat while private resident memory grows, change instruments and investigate those owners. Increasing the garbage-collection frequency cannot release memory that the runtime does not own. Measure the floor after eviction With an appropriate size or expiry bound, repeated churn leaves a post-collection floor near a hundred two mebibytes. A normal allocator rises between collections. Retained old data changes the baseline after cleanup. Ana also checks hit rate and correctness for active tenants. Preventing a leak means ending ownership at an explicit point. Apply the diagnosis A bounded cache may grow during warmup and then stabilize at its configured size. It can still be too large for a container. Fixing retention rules addresses objects whose ownership should have ended; shrinking a cache addresses an intentional capacity choice. Validate memory, hit rate and latency after the specific change.