Skip to main content
gamedev.net
🔒 Locked

[.net] Controling memory usage

Started by REspawn 2 replies 1.1k views
Original Post
REspawn
REspawn
Hi, I have been reading tutorials on pointers and im still not sure if its what i want so I tought i would ask the people who know best. I have a file object that a file is loaded into, the user can edit it and save back to the physical file as they please. They can then open another file, and this is once again opened into the same file object using the object = new object style creation. Yet my memory usage continues to rise, even if i set the object to null first. I also tried forcing a garbage collection and stil got nowhere. So what it comes down to is how can i control the ammount of memory used by my application? Thanks for any help, -Dave
BradSnobar
BradSnobar
Is it using unmanaged resources (does it implement idisposable)?

If so, then you can do something like this to release memory:

yourFileOjbect.Dispose();
yourFileOjbect = null;

Are there other objects in your object that take up memory?
You would want to clean them up too.

This might help GC collect to find the memory to reclaim faster.

I might be able to provide some more help if you provide a snippet of code to examine.
iwandi
iwandi
Maybe you have some code like this.

Doc = new Doc();Doc.Load(Path);SomeObject.Doc = Doc;Doc = null;


The Doc object is still avalebale bacse it is in Someobject.Doc.

You have to clear al refferences to the doc object in order to get it gc´t.

Doc = null;Someobject.Doc = null;
REspawn
REspawn
Thanks guys, im just looking at some IDisposable tutorials now, thanks for the help.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.