Memory Leaks

tehon3299

Centurion
Joined
Jan 6, 2003
Messages
155
Location
Liverpool, NY
I realize in .NET that it garbage collects automatically when needed but I am still getting memory leaks. I have a program that acts as a Robot for the web and it gets links on pages and goes to all those pages and gets those links and so on. But my memory is getting used up little by little when I let it run for about an hour. Any ideas?
 
Make sure you're calling .Dispose on any objects that support it, when you are finished with them.
 
im not sure but i dont think so. Im not sure again but if .NET is anything like java, all java object extend (originally) from the Object class, i guess .NET does this too (all object have GetType()). If you look at the Object memebers, it does not contain a dispose method.

If you look in the MSDN documentation, it tells you to impliment a dispose method if your own classes - i guess (AGAIN not sure) that most System.* object will impliment this.
 
GC.GetTotalMemory(True)
That call will force the garbage collector to perform a collection and returns the amount of heap space the program has allocated.
 
I've just added a dispose method to two of my RSS classes, RSSGet() and RSSFeed() (latter is a data holding class), and Disposing of RSSGet() just after use (it returns a RSSFeed) saved just under 2 meg of ram! So its definatly worth it.
 
Back
Top