On a recent client engagement I had to investigate what appeared a to be a memory leak in a managed application. The program was running for about a week now and it appeared to slowly degrade in performance over time. Although it appeared healthy at only about 245 MB of memory used, I decided to investigate. The fastest way in my opinion to track down leaks in a running environment is to attach Windbg and use SOS:
- Download the appropriate release of the system debugger. Its location on the Microsoft Download site changes every now and then, but right now it is located at:
- http://www.microsoft.com/whdc/devtools/debugging/installx86.Mspx for 32 bit platforms
- http://www.microsoft.com/whdc/devtools/debugging/install64bit.mspx for 64 bit platforms.
- Start Windbg and attach it to your application.
- Load SOS:
.loadby sos mscorwks
- Dump the heap stats: