wyrd Posted August 7, 2003 Posted August 7, 2003 If your class implements IDisposable, is it guaranteed to be called by the application that it was created in when the application exits? For example, you forgot to Dispose of a class or you have a class that has a static member which is implements IDisposable. In both cases, will the application call Dispose for you when it is exited? Quote Gamer extraordinaire. Programmer wannabe.
Administrators PlausiblyDamp Posted August 7, 2003 Administrators Posted August 7, 2003 IIRC Dispose will not be called automatically when the program exits. however if you override the finalize method in a class this will automatically be called (sometime after the object goes out of scope and before the application terminates). MS info on the subject... http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconfinalizedispose.asp also http://www.vbinfozine.com/a_disposable.shtml has an idea or two. if you are using C# though a new keyword 'using' can be used. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html/vclrfcsharpspec_8_13.asp this will call the Dispose method automatically Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
*Experts* Volte Posted August 7, 2003 *Experts* Posted August 7, 2003 The memory that belongs to managed objects will be released automatically and collected by the garbage collector when it is no longer needed (i.e. when the program exits). Memory for unmanaged resources (such as GDI32 objects) needs to be manually freed, though. Quote
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.