Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
215
Critical Error/Memory leak?
posted

I've noticed that I have this huge memory leak.
My app relies heavily on infragistics ui components, and our code creates
And destroys many UserControls that comprise mostly of UltraTextEditors.
After some research I found that the constructor is not called on ANY control that contains an UltraTextEditor (and probably other editors as well).

This seemed so weird to me that I started a new project, that contains a main form, and a single user control, which in turn contains a single UltraTextEditor.
 I added a destructor to this control, and set it to print a message to the debug console.
To the main control I added a single button that creates my user control and looses reference to it, and then a call to GC.Collect();.

 If the control contains the UltraTextEditor, the descructor is never called, if I remove the line with "this.controls.add(ultraTextEditor1); " the destructor is called as expected.
Why does this happen? Is there some setting I need to know of somewhere that prevents my control from being GCed? Does the UltraTextEditor save a reference to the parent class in some static place that never gets out of scope?

Parents
  • 37774
    posted

    I'm not sure I completely follow this.  Are you disposing the UserControl too?  When you add the UltraTextEditor to the UserControl's Controls collection, the UserControl itself will hold onto the reference to the editor until the UserControl itself is disposed, which is why you're are seeing everything work when you remove 'this.controls.add...".

    -Matt 

Reply Children