Computing.Net > Forums > Programming > How to free up memory in C# apps?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

How to free up memory in C# apps?

Reply to Message Icon

Name: Leo the 28C (by Sulfurik)
Date: June 6, 2005 at 16:50:13 Pacific
OS: Windows XP SP2
CPU/Ram: 2.8 GHz/448 MB
Comment:

Hello everyone! :D
OK, I made a program, and I've been looking at Task Manager while I use the program, and I've been seeing that each time I open a file (even though I close the StreamReader after I use it...) or click something, the mem. usage increases! How do I fix this? How can I free mem. space? By the way, isn't 16+ MB of RAM for a text editor too much? Thanks! ;)



Sponsored Link
Ads by Google

Response Number 1
Name: Chi Happens
Date: June 7, 2005 at 08:27:09 Pacific
Reply:

C# will collect the garbage and clear out memeory for you, but the more you use static types (such as string) the more space will be allocated as your program runs.

If you want to force garbage collection, set your objects to - null when you are done with them.

For forms, you can call Dispose and then set it to null.

Hope this helps,
Chi


0

Response Number 2
Name: Leo the 28C (by Sulfurik)
Date: June 7, 2005 at 21:48:44 Pacific
Reply:

Well, I set all the StreamReaders/Writers, Save/OpenFileDialogs, etc, to null, but it still takes more memory each time I go to open/save a file... How can I fix this? Thanks! ;)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: How to free up memory in C# apps?

Questions on allocating memory in C www.computing.net/answers/programming/questions-on-allocating-memory-in-c/14721.html

How to use string array in C++? www.computing.net/answers/programming/how-to-use-string-array-in-c/9478.html

How to disable Windows errors in C www.computing.net/answers/programming/how-to-disable-windows-errors-in-c-/11257.html