none
Unregistering BingingNavigator events RRS feed

  • Question

  • I'm trying to remove the memory leak(s) my C# winforms app has at the moment. At the moment I'm doing this by using a memory profiler (dotTrace), opening a form, closing it, and dumping the memory. Looking at the dump, I'm focusing on the "Incoming References", as from what I have learned of late, this is preventing the form from unloading from memory properly.

    I have had some success here - I have managed to unregister a lot of events. Most of them were kind of obvious - there were clues as to what events was causing them, and unregstering them was as easy as putting a matching "-=" call in the Dispose method.

    Others are not so obvious. The one I'm focusing on in this thread is (I think) related to the BindingNavigator. In the image below you will see the output from the dump in dotTrace. I have selected the "Incoming References by Objects", and expanded the node that I think is related to the BindingNavigator (I have highlighted the section that gives me a clue to this).

    Now, my question is, what is causing this? I cant see any events that the binding navigator has against it, so I'm not sure what events I should be de-registering.

    Am I missing something? Am I on the right track? Am I mis-interpreting the memory dump?

    Monday, April 9, 2012 9:25 AM

All replies

  • This should be by design. It generates by the .Net framework. Also it handles by the .Net framework.

    Hope it helps.


    Life is not so easy.......

    Thursday, April 12, 2012 2:57 AM
  • This should be by design. It generates by the .Net framework. Also it handles by the .Net framework.

    Hope it helps.


    Life is not so easy.......

    Sorry, I dont follow. What is by design? The bindingnavigator being linked to these event handlers?

    Do I need to somehow release it from these event handlers? And if so, how?

    Thursday, April 12, 2012 3:03 AM
  • Hi Fweee,

    One solution can be, you can go and de-register th event in Dispose method.


    Regards, http://shwetamannjain.blogspot.com

    Thursday, April 12, 2012 3:08 AM
  • Hi Fweee,

    One solution can be, you can go and de-register th event in Dispose method.


    Regards, http://shwetamannjain.blogspot.com


    Thanks Shweta, but I'm already doing that.
    Thursday, April 12, 2012 3:11 AM