What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
A managed memory leak in .NET occurs when objects an application no longer needs remain reachable, preventing garbage collection from reclaiming them. To find one, first confirm that memory keeps growing under a repeatable workload; then compare heap evidence, inspect the references retaining suspect objects, change the responsible owner or lifecycle, and repeat the workload to verify the result.
How can you tell whether memory keeps growing?
Memory use rises naturally while an application allocates objects. A temporary increase that later falls is not the same as persistent growth. Run a repeatable workload that resembles the conditions where the problem occurs, and watch runtime counters before collecting a dump. Microsoft’s memory-leak tutorial recommends confirming growth first and comparing data from different points in time.
As an Amazon Associate I earn from qualifying purchases.
dotnet-counters ps
dotnet-counters monitor --refresh-interval 1 -p <process-id>
Use the process ID for the target application. These commands are from Microsoft’s tutorial, whose sample prerequisites specify .NET Core 3.1 SDK or later; tool behavior and interfaces can vary by runtime version. Consult the current dotnet-counters documentation for version-specific usage.
How do you capture and analyze a .NET memory dump?
When counters show persistent growth, collect comparable heap evidence. A process dump lets you inspect objects and their retaining references with SOS. If the question is what is increasing, collect one dump and another after a similar interval or workload, then compare their type statistics.
#1 Best Overall
-
Install the global tool if it is not already available:
dotnet tool install --global dotnet-dump. See Microsoft’s dotnet-dump documentation for supported platforms and requirements. -
Collect a dump from the target process:
dotnet-dump collect -p <process-id>. -
Open the resulting file for SOS analysis:
dotnet-dump analyze <dump-path>.The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
At the SOS prompt, summarize object counts and sizes by type:
dumpheap -stat. To narrow the report to a namespace or type, use a filter such asdumpheap -type MyCompany.Component -stat. -
For a suspect object, inspect its retaining references with
gcroot. Follow the root path back to the application-owned object or collection that keeps it alive.
A large type in dumpheap -stat is a lead, not proof of a leak. The key evidence is whether its retained population grows across comparable captures and which live reference chain keeps those objects reachable. Microsoft’s example traces a Customer through a CustomerCache and list or array objects, illustrating how cached entries can remain alive.
Rank #3
What should you check before collecting a dump?
-
Run collection as the same user as the target process or as root. On Linux and macOS, the target and diagnostic tool need to use the same
TMPDIR.Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
In containers, collection may require
SYS_PTRACEand a suitable security profile. Check the tool’s requirements for the environment. -
Plan for the memory impact. Full or heap dumps can page in substantial virtual memory and push a container over its limit, potentially causing it to be terminated.
Rank #4
-
Restrict access to dumps and handle them as sensitive data. A dump can contain information from the process; Microsoft’s dump guidance discusses their uses and security implications.
Which .NET memory diagnostic tool should you use?
| Situation | Starting point | What it tells you | Main trade-off |
|---|---|---|---|
| Determine whether memory is persistently growing while the app runs | dotnet-counters |
Runtime counters help establish the trend before deeper diagnostics. | It does not identify the reference chain retaining particular objects. Microsoft tutorial |
| Inspect heap contents and find retaining references | dotnet-dump with SOS |
Heap statistics and root paths help connect retained objects to an owner. | Dump collection can be costly in memory-limited environments. Microsoft tool guide |
| Collect live GC heap data for counts and roots | dotnet-gcdump |
Captures GC heap information from a live process for analysis. | Large heaps can produce incomplete graphs, and collection consumes memory. Microsoft tool guide |
| Investigate in Visual Studio on Windows | Memory Usage snapshots; .NET Object Allocation tool | Snapshots compare retained objects and paths to roots; allocation profiling identifies allocation-heavy call paths. | Profiling can slow the application. Memory Usage guide; Object Allocation guide |
When is dotnet-gcdump useful, and when is it a poor fit?
dotnet-gcdump gathers GC heap data from a live process using EventPipe. It can help compare object counts and inspect roots, but collection induces a generation 2 garbage collection. For a sufficiently large heap, event data may be dropped, leaving an incomplete heap graph; Microsoft recommends collecting a process dump in that situation.
Account for memory pressure before using it in a constrained environment: the target’s event buffer can grow up to 256 MB, and the tool itself also consumes memory. See Microsoft’s dotnet-gcdump documentation for collection behavior and limitations.
How can Visual Studio help on Windows?
In Visual Studio, use the Performance Profiler’s Memory Usage tool to monitor a scenario and take snapshots at useful points. Compare snapshots to see differences in object counts and bytes, managed types, and paths to roots. Microsoft recommends the Performance Profiler workflow for release builds in its Memory Usage guide.
The .NET Object Allocation tool answers a related but different question: which execution paths create objects? It can help trace allocation-heavy call paths, complementing retained-object analysis rather than replacing it. Profiling can slow the application; Microsoft describes adjusting the sampling rate when tracking every allocation is unnecessary in its Object Allocation tool guide.
How do you fix the leak and confirm the change?
Use the root path to identify the application’s actual owner of the retained objects. Then inspect that owner’s lifecycle: for example, whether a cache, collection, event subscription, or other long-lived reference is keeping entries reachable longer than intended. Apply a fix to the retention or cleanup behavior shown by the evidence, not to a presumed cause.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsCalling Dispose is appropriate for releasing resources owned by disposable objects, but it does not by itself remove arbitrary managed references or make an otherwise reachable object collectible. After changing the responsible ownership or cleanup behavior, run the same workload again and compare counters, dumps, or Visual Studio snapshots over time. A successful fix should stop the unwanted retained population from continuing to grow under those conditions.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




