Note that there are some explanatory texts on larger screens.

plurals
  1. POMemory leak, again!
    primarykey
    data
    text
    <p>A couple of weeks ago I was having trouble with memory leaks associated with a ContextMenuStrip. That problem was fixed. <a href="https://stackoverflow.com/questions/2792427/memory-leak-with-contextmenustrip/">See that question here</a></p> <p>Now I'm having similar issues with ToolStrip controls. As in the previous problem, I'm creating a large number of UserControls and adding them to a FlowLayoutPanel. Each control creates a ToolStrip for itself in its constructor. When a control is removed from the FlowLayoutPanel (the only reference to the control), it seems memory for the ToolStrip is not being released. </p> <p>However when I comment out the code that creates the ToolStrip the memory leak doesn't happen.</p> <p>Is this the same sort of issue as the previous one - I need to set the ToolStrip to null? I don't see how that could be since this time the control is creating the strip itself, and all the button events etc are handled inside it. So shouldn't everything be GC'd when the control is no longer referenced?</p> <p><em>EDIT:</em> As to the comments, the thing I don't understand is originally I was "making" my own toolstrip out of a panel and some labels. The labels were used as buttons. No memory leaks occurred this way. </p> <p>The only thing I've changed is using a proper ToolStrip with proper buttons in place of the panel, but all the event handlers are wired the same way. So why is it now leaking memory?</p> <p>EDIT2: I was just about to post my code but reread the question Dave linked to. It turns out it was the UserPreferenceChangedEvent problem of the ToolStrip. If I set the ToolStrip.Visible property to false, the memory leak doesn't happen!</p> <p>Now, could I do this in the Dispose method? If so how? I tried copying some code but I get a compile warning: "MyToolStrip.Dispose()' hides inherited member 'System.ComponentModel.Component.Dispose()" I just don't understand the IDisposable interface.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload