C# & CLR Internals (50 Qs)•Part 3: CLR Internals, Native AOT & Production Diagnostics (25 - 35)
How do you capture and diagnose Memory Leaks in production .NET applications using dotnet-dump?
senior LevelCode ExampleMemory Management
In Simple Words:
Use the cross-platform CLI tool dotnet-dump:
bash
# 1. Capture memory core dump:
dotnet-dump collect -p <pid>
# 2. Analyze the dump file:
dotnet-dump analyze core_dump
> dumpheap -stat # List types by memory footprint
> dumpheap -mt <MethodTable> # List specific instances
> gcroot <ObjectAddress> # Trace strong reference chain keeping object alive