I am not sure how the user defined class objects are garbage collected. Do I need to implement IDisposable interface on every class and call the dispose() method on it to free the memory?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No. Every normal managed .NET object gets garbage collected when you stop referring to it. IDisposable means that you you will implement a Dispose() method that needs to be called by the caller — it usually releases things that aren’t garbaged collected. It also helps with having a deterministic place to release memory.
Check out the IDisposable pattern to make sure you do it right:
http://www.atalasoft.com/cs/blogs/stevehawley/archive/2006/09/21/10887.aspx