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
  • 45049
    posted

    In a previous post in this thread, we confirmed that to apply changes to use a weak event handler model would be a non-trivial implementation.

    I'm pleased to announce that we've implemented this change for the release of NetAdvantage for .NET 2010 Volume 1.

    Please note that the recommended practice remains to dispose references to your controls yourself, rather than relying on destructors and garbage collection, in any scenario where disposal isn't done for you.  Ensuring that your controls are disposed remains the best solution that is available in NetAdvantage for .NET 2009 Volume 2 and older, and will continue to be a best-practice recommendation even after the new version of the toolset containing this change is released.

    Thank you all for your input and your patience.

Reply Children