© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•16mo ago•
22 replies
ToastedTuna

✅ Winforms not freeing memory when disposing of control

void NewButtonOnClick(Button btn)
{
    //Delete the button completely, write code
    btn.Parent.Controls.Remove(btn);
    btn.Dispose();
    btn = null;
}
void NewButtonOnClick(Button btn)
{
    //Delete the button completely, write code
    btn.Parent.Controls.Remove(btn);
    btn.Dispose();
    btn = null;
}


The memory usage continues going up
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ WPF not disposing of memory on window close
C#CC# / help
3y ago
Winforms control not updating on window resize
C#CC# / help
16mo ago
✅ MultiLine error on custom user control WinForms
C#CC# / help
9mo ago
Exception about disposing DbContext
C#CC# / help
3y ago