memory-leaksclrclrprofiler

Can CLR Profiler be used to find memory leaks


My .NET application has memory leak. Few people seem to recommend using CLR Profiler for this pupose I am a bit lost on the idea. To me in order to find a memory leak, tool should compare two memory states that can give you statistics like growth in objects between two states. So in my mind, if a tool cannot compare two (or more) memory states, it cannot be used for detecting memroy leak. Obviously things like performance counters is bit different concept where you can trend the memory usage.

So my question is really if someone can explain how exactly CLR Profiler can be used to detect memory leaks?


Solution

  • Well it depends on what kind of memory leak you have.

    We had a reproducible one, where we new that a certain chain of events should always leave a clean table after work was done - but it wasn't.

    So we simple setup a test where we did it a couple of thousand times - then we looked at those objects (bigger in number) in the heap graph and at the "root"-object the cause of why the objects where still alive. It helped to solve our problem...