3

I'm inheriting an existing application that has a number of memory holes. I suspect they are caused by event handlers that are subscribed but never released. What tools or resources can I use to help identify the objects that are being held on to even after they have gone out of scope because of an open event handler?

Jim Wooley
  • 10,169
  • 1
  • 25
  • 43
  • Not directly your answer but I suggest you read this: http://www.interact-sw.co.uk/iangblog/2004/07/07/circulareventrefs – Ta01 Aug 25 '11 at 17:11
  • WinDbg + psscor2 / SOS gives you awesome commands like !GCWhere, !FindRoots !HandleCLRN, !GCRoot, etc. – vcsjones Aug 25 '11 at 17:13

2 Answers2

2

I've had success using redgate's ANTS memory profiler to chase down similar issues. It's not an inexpensive product, but in my experience it's proven very useful and been worth the cost.

PaulF
  • 1,133
  • 8
  • 14
0

JetBrains also has a memory profiler: dotTrace Memory. I've got it but haven't used it enough to make a recommendation. It's not free either (unless you win a license at a user's group). :)

I'd also check to insure that all objects whose classes implement IDisposable are properly disposed. A using block will insure this even if an exception occurs. While that involves unmanaged resources rather than memory, in practice there may be little difference.

See also Detecting "leaked" IDisposable objects, which mentions multiple memory profilers.

Community
  • 1
  • 1
TrueWill
  • 25,132
  • 10
  • 101
  • 150