EventHandler static memory leaks in structure

I am trying to troubleshoot some memory issues that are occurring in our .NET WinForms application. I use SciTech.NET Memory Profiler as well as dotTrace and they all seem to blame root allocations with static event handlers in .NET Framework controls. From google'ing around, I found posts about this here and here , but this is reportedly reported in version 1.1 of the .NET Framework and the fixes promised for 2.0. We are working on 2.0 and we still see these problems. The top 25 memory offenders I've found point to these static event handlers and in particular SystemEvents.UserPreferenceChanged. This guywent to meet to find a way to unwind these handlers. I haven't tried this yet, but I tried the workaround mentioned in the Microsoft support ticket and none of them worked for me.

I am well aware of the potential for leaking event handlers (especially long live static handlers), but this one is almost out of control. Anyone have any experience?

0


source to share


2 answers


For really deep problems with memory leaks in the CLR, I think windbg is the best tool. If you can get past the critical syntax, this is an amazingly efficient debugger and leak. The downside is that it is not very intuitive and there is a very steep learning curve.

The best way to learn windbg is to do it. Here are some articles that talk about using windbg to track leaks.



+1


source


I don't know if WinDBG will help here. It looks like this is indeed a bug in the framework. Is there a way to post a simple reprogramming? If so, then I could dig into what's going on and see if there is a workaround. Otherwise, it would be better to open a ticket for Connect . They speak very well to people.



If you want to examine it using WinDBG, you can examine what's going on on the heap to see what's going on. Start looking at where the objects that hang around are anchored to. I assume you will see pretty much what you see in the profilers above. The tricky thing with WinDBG is that it can tell you what you want - you need to know what questions you want to get into it.

0


source







All Articles