----------------------------------------------------------- New Message on MumbaiUserGroup
----------------------------------------------------------- From: Vishnu-Chivukula Message 3 in Discussion Both Dispose and destructor are used reclaiming memory. But there is a major difference in the way they are called by the CLR. To use the dispose method your class must implement the IDsiposable interface. When you explicitly call the dispose method, the object is cleaned up. If you are using any unmanaged resource (that which dosen't target the runtime) you might end up with memory leaks if you dont clean them up. One example can be the connection object or a windows handler, which are unmanaged. This approach is recomended. Coming to destructor, if you are from a C/C++ background this might seem like the only logical choice. But in managed world of .NET destructor are very different. Destructors in .NET are 'undeterministic'. That is you dont know when they will be called. When the system is low on memory, the garbage collector (a low priority thread) walks through the heap trying to clear up unreferenced objects. It is only then the object cleaned up. Till then it stays in memory. Also destructors generally dont work properly with unmanaged objects. Happy Coding. ----------------------------------------------------------- To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings. http://groups.msn.com/mumbaiusergroup/_emailsettings.msnw Need help? If you've forgotten your password, please go to Passport Member Services. http://groups.msn.com/_passportredir.msnw?ppmprop=help For other questions or feedback, go to our Contact Us page. http://groups.msn.com/contact If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list. mailto:[EMAIL PROTECTED]
