• Advertisement
Sign in to follow this  

[.net] Controling memory usage

This topic is 4176 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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;

Share this post


Link to post
Share on other sites
Thanks guys, im just looking at some IDisposable tutorials now, thanks for the help.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement