Set ConnObject = NOTHING?

Results 1 to 4 of 4

Thread: Set ConnObject = NOTHING?

  1. #1
    Join Date
    Dec 1969

    Default Set ConnObject = NOTHING?

    I have read in many articles that you MUST close your connection object as soon as possible and then set it to NOTHING. I have found that by closing the connection, you are releasing the connection to the connection Pool. However, Setting the connection to NOTHING seems to destroy the object and not release it to the pool at all. <BR><BR>I did a test by running a small site with approx. 10 connections. In the first test I closed the connection Object but I didn&#039t set it to NOTHING. After running SQL Trace I found that only one connection had been made.<BR><BR>In my next test, I ran the exact same site only this time I set the connection Object to NOTHING after closing it. My results in SQL Trace was that I had Created 10 seperate connections.<BR><BR>More interesting, the speed in my first test took about 25% of the time as the second test.<BR><BR>Someone please enlighten me.

  2. #2
    Paul Payton Guest

    Default RE: Set ConnObject = NOTHING?

    Your results sound exactly as expected to me.<BR>it shows that by not setting the connection to nothing it doesn&#039t detroy it.<BR>The point is to destroy it.<BR>If you are going to use it again in the same script then don&#039t destroy it. But as soon as your done with it do away with it.<BR>If you don&#039t it will stay open and hog memory after the script is done and you have moved on to another website.<BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: Set ConnObject = NOTHING?

    Paul is absolutly correct. Connection pooling is always question poping up here and there. If you have a qurey that pulls the SAME data and does not vary then connection pooling will benifit keep the connection to the same place. If you need to get different data each time then connection pooling ranks up there with all those great tutorials on using sessions for shopping carts ;) (A bad idea). Using NOTHING will destroy it and free up that memory. In short creaet and destroy as quicly as possible in a dynamic environment.<BR><BR>Hope that helps

  4. #4
    Darren Hoefgen Guest

    Default RE: Set ConnObject = NOTHING?

    Everything that I have read and my experience is that you want to CLOSE the connection as soon as you are done with it. This is the easy and obivious one. <BR><BR>HOWEVER You need to explicitly destroy ALL objects that you have instantiated in you script at the end of your script. This is done by "SET OBJECT = NOTHING". Destroying it will keep your application for using memory that isn&#039t necessary. <BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts