0

I know this question has been asked before, but a lot of the info out there seems outdated.

Is it possible to isolate a memory leak in a .NET application to an object type or namespace? Is there a free, up-to-date tool that can do this?

Currently I'm using perfmon to monitor memory usage in private bytes and the heap, but I would like to isolate the offending class or piece of code.

McGarnagle
  • 101,349
  • 31
  • 229
  • 260
  • 2
    perfmon isn't much use. VS enterprise if you have it comes with one built in which does the job. Otherwise just google free .net profiler, any vaguely sensible one will do the job, it's waht they are for. Some work better and some are easier to use than others. THis might be of use if you didn't find it. http://stackoverflow.com/questions/3927/what-are-some-good-net-profilers. We use Antz, though most potential ones are found through religious use of FxCop – Tony Hopkinson Aug 25 '12 at 00:24

1 Answers1

1

The CLR Profiler (microsoft.com) did the job for me. After attaching it to a process, it can show a snapshot graph of objects in the heap.

Here are the steps I followed:

  1. Run tasklist in the console to get my Windows Service's process ID
  2. Attach the CLR profiler to the process
  3. Click "Show Heap Now" to view the heap graph

From looking at the heap graph, it was immediately clear that the Sharepoint client was guilty of gobbling up memory and not releasing it.

McGarnagle
  • 101,349
  • 31
  • 229
  • 260