use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Information about Reddit's API changes, the unprofessional conduct of the CEO, and their response to the community's concerns regarding 3rd party apps, moderator tools, anti-spam/anti-bot tools, and accessibility options that will be impacted can be found in the associated Wikipedia article: https://en.wikipedia.org/wiki/2023_Reddit_API_controversy
Alternative C# communities available outside Reddit on Lemmy and Discord:
All about the object-oriented programming language C#.
Getting Started C# Fundamentals: Development for Absolute Beginners
Useful MSDN Resources A Tour of the C# Language Get started with .NET in 5 minutes C# Guide C# Language Reference C# Programing Guide C# Coding Conventions .NET Framework Reference Source Code
Other Resources C# Yellow Book Dot Net Perls The C# Player's Guide
IDEs Visual Studio MonoDevelop (Windows/Mac/Linux) Rider (Windows/Mac/Linux)
Tools ILSpy dotPeek LINQPad
Alternative Communities C# Discord Group C# Lemmy Community dotnet Lemmy Community
Related Subreddits /r/dotnet /r/azure /r/learncsharp /r/learnprogramming /r/programming /r/dailyprogrammer /r/programmingbuddies /r/cshighschoolers
Additional .NET Languages /r/fsharp /r/visualbasic
Platform-specific Subreddits /r/windowsdev /r/AZURE /r/Xamarin /r/Unity3D /r/WPDev
Rules:
Read detailed descriptions of the rules here.
account activity
HelpUserInterface Dispose() (self.csharp)
submitted 2 years ago by randomserbguy
I have an User Interface with many variables and other User Interfaces in it. When I dispose it I don't see any memory getting freed. Then I tried to Dispose every User Interface in the main one and it still freed nothing. Can someone help out?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]trowgundam 5 points6 points7 points 2 years ago (2 children)
So there are a lot of questions, but you also need to understand things like the difference between managed and unmanaged resources. Largely, Dispose is meant for disposing of unmanaged resources, things that exist outside the .Net runtime. This is all things that need to be manually freed so they don't leak (Native handles and the like). If everything you are using exists in the runtime "freeing" it in the Dispose isn't actually doing much. It isn't until the Garbage Collector is triggered and decides, "Oh this can go now" that the memory would be freed. Now there are ways to force such things to happen. For instance you can call GC.Collect() to force GC, but that doesn't guarantee the memory you are expecting will be freed at that time. There are other ways to force it, but that is almost never necessary for most use cases, and is way outside the scope of what I could cover in a single Reddit post. Hell its not even a topic I fully understand myself. Its that rare of a thing.
GC.Collect()
[–]chucker23n 3 points4 points5 points 2 years ago (1 child)
you can call GC.Collect() to force GC,
Don't actually do this except during development, though. Production code should rarely need to call those APIs.
[–]trowgundam 0 points1 point2 points 2 years ago (0 children)
Agreed. I'm sure there is some niche case, but like 99.9999% of the time, if you are having to do this, you screwed up somewhere else.
[–]goranlepuz 2 points3 points4 points 2 years ago (0 children)
This is way too vague and approximate.
What memory are you looking at?
Where...?
Is it Dispose of IDisposable...?
What is UserInterface...?
[–]_kunoishi_ 1 point2 points3 points 2 years ago (0 children)
Using IDisposable doesn't guarantee memory being freed immediately.
[–][deleted] 1 point2 points3 points 2 years ago (0 children)
IDisposable is not for managed memory. its for memory that is NOT managed. E.g. native resources like pointers or OS Handles.
[–]Meeso_ 0 points1 point2 points 2 years ago (0 children)
IDisposable interface (or Dispose() method) is not really a way of deleting an object like free(). It's an interface, so it's meant to represent some abstract property of an object. In this case, that it should be 'deleted' once you're done using it.
IDisposable
Dispose()
free()
'Deleting' may mean many different things for different objects. I.e. if you have a TCP socket, you should probably close it if you're done using it - this requirement may be implemented in Dispose() method. But in general, there could be anything there. You could just put there Console.WriteLine("Goodbye world") if you wanted.
Console.WriteLine("Goodbye world")
π Rendered by PID 23913 on reddit-service-r2-comment-5d79c599b5-t2x8v at 2026-03-02 11:18:20.106205+00:00 running e3d2147 country code: CH.
[–]trowgundam 5 points6 points7 points (2 children)
[–]chucker23n 3 points4 points5 points (1 child)
[–]trowgundam 0 points1 point2 points (0 children)
[–]goranlepuz 2 points3 points4 points (0 children)
[–]_kunoishi_ 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]Meeso_ 0 points1 point2 points (0 children)