Re: About Dispose
From: Nicholas Paldino [.NET/C# MVP] (mvp_at_spam.guard.caspershouse.com)
Date: 10/13/04
- Next message: Mickey Williams [C# MVP]: "Re: About Dispose"
- Previous message: Reza: "Re: a good reference"
- In reply to: Sam Sungshik Kong: "About Dispose"
- Next in thread: Sam Sungshik Kong: "Re: About Dispose"
- Reply: Sam Sungshik Kong: "Re: About Dispose"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 13 Oct 2004 13:31:51 -0400
Sam,
If the object in question implements IDisposable, then you should call
it as soon as you possibly can. The reason for this is that it represents
some resource that should be released right away (wether it is memory, file
handles, database connections, etc, etc).
If you let them linger around, then its true, a proper implementation of
the IDisposable method will make sure that they *eventually* get cleaned up,
but in order to keep your app (and the rest of the system running)
efficiently, it is in your best interests to call the Dispose method as soon
as you are done with them.
Hope this helps.
"Sam Sungshik Kong" <ssk@chol.nospam.net> wrote in message
news:uIDjsiUsEHA.2144@TK2MSFTNGP10.phx.gbl...
> Hello!
>
> A disposable object's Dispose() method can be called either explicitly by
> the programmer or implicitly during finalization.
> If you call Dispose, the unmanaged resources are released earlier.
> Thus, if you think the unmanaged resources are important, you call Dispose
> explicitly.
>
> My question is what's the criteria to decide the unmanaged resources are
> important.
>
> I think...
> files are important.
> DB connections are important.
>
> What about window handles?
> What about Graphics?
>
> I want to hear what you think about it.
>
> Thanks.
>
> Sam
>
>
- Next message: Mickey Williams [C# MVP]: "Re: About Dispose"
- Previous message: Reza: "Re: a good reference"
- In reply to: Sam Sungshik Kong: "About Dispose"
- Next in thread: Sam Sungshik Kong: "Re: About Dispose"
- Reply: Sam Sungshik Kong: "Re: About Dispose"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|