Memory & GC
Reveal answer and reasoning
Process working set, GC heap snapshots, cumulative allocation counters and pause-duration counters have different scopes and update semantics. A last-collection heap value may remain unchanged while current process memory rises. A cumulative allocated-byte counter rises even when all recent temporary objects die. Compare rates or deltas over a clearly defined interval and record the collection index where relevant.
Current .NET runtime metrics expose separate observations for heap size including fragmentation, fragmentation by generation, committed GC memory and process working set. Those values cannot be substituted for one another. If resident process memory grows while comparable managed live evidence remains flat, investigate native and other process allocations rather than declaring the collector defective. Conversely, a working set plateau can hide a growing managed graph that has not yet exhausted available capacity.
Start with type distribution and representative instances, then inspect retaining paths. A large byte-array total might belong to active requests, a pool, a cache or a native interop workflow. Those owners imply different fixes. A type histogram tells you what exists, not why it exists or whether its lifetime is wrong. A root path can establish ownership but still needs comparison with the intended business boundary.
Use tools compatible with the target runtime and platform. dotnet-counters provides low-friction metrics, dotnet-dump and SOS support deeper object and root analysis, and dotnet-gcdump reconstructs managed graph evidence using a collection-triggering process. Tool availability, overhead and exact commands vary. A collection-triggering diagnostic changes the process being observed, so label that intervention rather than presenting it as a passive continuous snapshot.
What a strong answer covers
- A managed heap snapshot is not a complete process-memory account.
- Allocation rate, last-GC snapshots and RSS need aligned observation windows.
- A retaining path proves ownership; a large type count alone does not prove a leak.
Common pitfall
Subtracting an unaligned managed snapshot from working set and labeling the remainder an exact native-memory total.
Follow-up questions
- How do you prove two snapshots came from the same replica and workload phase?
- Which result would falsify your proposed retention fix?
Self-review
Choose what to revisit. These marks are your own assessment and are separate from lesson completion.