Skip to content
AITroveRead. Build. Understand.
Make this comfortable

Memory growth: distinguish retained data from useful cache

Last updated: 5 Oct 20266 min read
tutorial
AdvancedBy AITrove Editorial

Resident memory can rise because of live application objects, allocator arenas, direct buffers, mapped files, or page cache charged to a cgroup. A leak is memory that remains reachable or otherwise unreclaimable after the work that required it has ended. A cache may grow deliberately and then stabilize or shrink under pressure. One flat traffic window cannot establish either behavior; use repeated, comparable work cycles and measure what remains after each cycle.

Operational decision

A fraud-scoring service rises from 310 to 690 MiB after eight batch windows. Replay a fixed 47,000-record batch three times in a disposable environment. Record memory.current, process RSS, anonymous versus file charge, application cache entry count, and post-cycle latency. If the heap's live set rises after every collection, capture a controlled heap profile; if RSS rises while live heap and cgroup charge stabilize, inspect allocator retention and mappings before rewriting business logic. Disable or bound one cache at a time, then compare throughput and tail latency. A restart that resets memory only proves the memory belonged to the process, not that it was leaked.

Output
Fraud scorer comparison
Batch input: 47,000 records, repeated three times
Window: before, peak, after each cycle
Signals: cgroup charge, RSS, anonymous/file split, live heap, cache entries
Decision: leak, bounded cache, allocator retention, or unresolved
Acceptance: stable post-cycle baseline with no latency regression

Cost and verification

A full heap capture is O(H) in live heap bytes and can pause or slow the service; profile a disposable replica first. A bounded cache trades hit rate for predictable memory use, so compare cache misses and downstream load after tightening it. Keep the batch input and runtime version fixed when comparing experiments. Alert on sustained growth paired with exhausted headroom or user impact, not on every healthy warm-up.

Common Mistakes

  • Do not call every RSS increase a memory leak.
  • Do not infer that a restart identifies the allocation source.
  • Do not shrink a cache without measuring its downstream cost.

Connected lessons

Practice and check

devops
memory-operations
Storage details