tehon3299 Posted March 22, 2003 Posted March 22, 2003 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? Quote Thanks, Tehon
*Gurus* divil Posted March 22, 2003 *Gurus* Posted March 22, 2003 Make sure you're calling .Dispose on any objects that support it, when you are finished with them. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
tehon3299 Posted March 22, 2003 Author Posted March 22, 2003 Can you call .Dispose on any object? Quote Thanks, Tehon
philprice Posted March 22, 2003 Posted March 22, 2003 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. Quote Phil Price� Visual Studio .NET 2003 Enterprise Edition Microsoft Student Partner 2004 Microsoft Redmond, EMEA Intern 2004
*Gurus* divil Posted March 22, 2003 *Gurus* Posted March 22, 2003 Classes that implement IDisposable have a Dispose method. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
*Experts* jfackler Posted March 23, 2003 *Experts* Posted March 23, 2003 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. Quote
philprice Posted March 23, 2003 Posted March 23, 2003 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. Quote Phil Price� Visual Studio .NET 2003 Enterprise Edition Microsoft Student Partner 2004 Microsoft Redmond, EMEA Intern 2004
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.