Francesco Granozio
Francesco Granozio

Reputation: 11

C# Windows Forms ToolStrip and MenuStrip memory leak

I'm creating a Windows Forms app in C# (.NET 4.7.2), I just added a ToolStrip and a MenuStrip. If I run the application the memory usage jumps to 600mb, too much for a Windows Forms application with only a ToolStrip and a MenuStrip, if I delete them both memory usage returns to normal . I did some research and found that there is a memory leak in ToolStrip and MenuStrip, I also tried this (ToolStrip memory leak), but didn't work. How this can be fixed?

protected override void Dispose(bool disposing)
{

    if (disposing)
    {
        var overflow = toolStrip1.OverflowButton.DropDown as ToolStripOverflow;
        if (overflow != null)
            overflow.Dispose();
    }


    if (disposing && (components != null))
    {
        components.Dispose();
    }
    base.Dispose(disposing);
}

Upvotes: 1

Views: 223

Answers (0)

Related Questions