Вопрос

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.

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top