Re: " //Clean Up managed resources " f&*ck
- From: Moty Michaely <Moty.Mi@xxxxxxxxx>
- Date: 19 May 2007 02:43:37 -0700
On May 19, 12:33 am, "Koliber (js)" <profesor_kinb...@xxxxxxxxxxxxxx>
wrote:
If sql connection is managed resource
why dispose if called from finaliser in pattern above
should leave it untouched?
The finalizer is called by the GC. Implementing a finalizer is the
only way to code things that needs to be done at instance collection
time (such as releasing internal unmanaged resources). Since Dispose
methods is responsible for cleaning resources, the finalizer code
usually calls the Dispose method.
Therefore, you are right - it's there to guarantee object disposal if
not called manually. But, again, the GC is not deterministic. The
finalizar can practically call the finalizer 10 minutes after it
really got pinned off... Therefore, manual disposal is a best practice
to make sure that unmanaged resources will not be held for 10 minutes,
for nothing....
And if sql connection is unmanaged resource
what the hell is managed resource and how
it can be explicite free'd? :(
Quote: "In Microsoft Windows terminology, managed code is computer
instructions - that is, "code" - executed by a CLI-compliant virtual
machine, such as Microsoft's .NET Framework Common Language Runtime,
or other CLI implementations from The Mono Project or the DotGNU
Project."
Taken from: http://en.wikipedia.org/wiki/Managed_code
Therefore, SqlConnection is a managed code that uses unmanaged
resources.
Hope this clears things..
Moty
.
- Follow-Ups:
- Re: " //Clean Up managed resources " f&*ck
- From: Koliber (js)
- Re: " //Clean Up managed resources " f&*ck
- References:
- " //Clean Up managed resources " f&*ck
- From: Koliber (js)
- Re: " //Clean Up managed resources " f&*ck
- From: Nicholas Paldino [.NET/C# MVP]
- Re: " //Clean Up managed resources " f&*ck
- From: Koliber (js)
- Re: " //Clean Up managed resources " f&*ck
- From: Moty Michaely
- Re: " //Clean Up managed resources " f&*ck
- From: Koliber (js)
- " //Clean Up managed resources " f&*ck
- Prev by Date: Re: " //Clean Up managed resources " f&*ck
- Next by Date: Configuring AspNetSqlProvider to use a different database
- Previous by thread: Re: " //Clean Up managed resources " f&*ck
- Next by thread: Re: " //Clean Up managed resources " f&*ck
- Index(es):
Relevant Pages
|