Re: Destructors...

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Chris Jackson (chrisjATmvpsDOTorgNOSPAM)
Date: 02/06/04


Date: Fri, 6 Feb 2004 13:15:27 -0500

Regarding pooling: unless you explicitly turn off pooling in your connection
string, then you will end up with connection pooling with a default number
of 100 connections. If you are using the connections in such a way that you
can't re-use them, then this pool will diminish even faster. This could
cause problems as your user base expands.

Regarding IDisposable: Unless you need to hold in the state of your object
some scarce resources, then you have no reason to expose this interface
yourself. You should, however, make a point to properly use this interface
in the objects you are using that expose this interface. If you are using
C#, you can use the using keyword to make this easy. For example:

using (SqlConnection myConnection = new SqlConnection(...)) {
    // do something with the connection
}

Using functions in much the same way as a try ... finally clause would,
guaranteeing to call Dispose as soon as you are done using the connection,
either releasing it to the pool or else returning those resources to the
system. With scare resources, you should make it a point to free them up as
soon as you have the opportunity to do so. Because garbage collection is
non-deterministic, you could run out of your scarce resources long before
you run out of the resources that trigger garbage collection.

-- 
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
-- 
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
-- 
"Paul M" <masonp@trials.bham.ac.uk> wrote in message 
news:ewVsdN96DHA.2044@TK2MSFTNGP10.phx.gbl...
>
> Hi folks,
>
> Given the nature of asp, when I'm constructing data bound middler tier
> objects, is it necessary to implement the Idisposable interface or is it
> good enough to rely on a Finalize call.
>
> Most of my applications will be using Forms authentication and as such the
> sql server connection objects will all have individual user id's i.e. no
> connection pooling, and because of the time between posts, I can't see any
> reason not rely on the normal garbage collection.
>
> Any comments would be much appreciated...
>
> Thanks...P
>
> P.S Since when did the Oxford English Dictionary spell Finalise with a Z??
> Bloomin' nuisance.
>
> 


Relevant Pages

  • Re: ado connection object in vb6
    ... "Global connection objects are bad in so many ways. ... The key is that ADO uses 'connection pooling'. ... "Pooling in the Microsoft Data Access Components" ...
    (microsoft.public.vb.database.ado)
  • Re: SQL Resets
    ... When we turn on connection pooling, it loads up pretty fast to throw the ... I tend to believe it has something to do with the connection pooling. ... Have you had a look at the SQL Server ... Have you tested the development environment with MaxUserPort=64534, ...
    (microsoft.public.sqlserver.connect)
  • Re: MDAC question
    ... The MDAC downloads are labeled by the ... I suggested that the ADO data library is ... He simply created a connection object and set its connection time ... Connection pooling is just the kind of 'hidden' ...
    (microsoft.public.vb.general.discussion)
  • Re: MDAC question
    ... The MDAC downloads are labeled by the ... I suggested that the ADO data library is ... He simply created a connection object and set its connection time ... Connection pooling is just the kind of 'hidden' ...
    (microsoft.public.data.ado)
  • Re: MDAC question
    ... The MDAC downloads are labeled by the ... I suggested that the ADO data library is ... He simply created a connection object and set its connection time ... Connection pooling is just the kind of 'hidden' ...
    (microsoft.public.vb.database)