Garbage collection issues in .NET
Are there any known issues with garbage collection in .NET? I have a C# Web forms application that sometimes stops responding for no apparent reason, and I suspect garbage collection may play a role here. Thoughts?

    Requires Free Membership to View

    When you register, you'll begin receiving targeted emails from my team of award-winning writers. Our goal is to provide a unique online resource for developers, architects and development managers tasked with building and maintaining enterprise applications using Visual Basic, C# and the Microsoft .NET platform.

    Hannah Smalltree, Editorial Director

    By submitting your registration information to SearchWinDevelopment.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchWinDevelopment.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

No, to my knowledge there are no problems with the .NET garbage collector. However, that doesn't mean you are not experiencing problems with object disposal because of misuse. Having said that, the honest truth is you're much more likely to find the source of your problem in your own code. I would try to carefully pinpoint the methods/classes that are involved with your lockups, and then try to understand how they relate to each other when the objects are invalid (i.e., after they have been disposed). The chances are much higher that you simply have a logic bomb over the chances that the .NET garbage collector is simply "locking up." You need to carefully review the code in your Dispose methods if you have modified them, as well as any cleanup methods that you would call as you try and close things down, whether they be Form classes or other classes. Take your time, insert some breakpoints, and begin debugging your code with an open mind.

This was first published in February 2005