Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll

my Blog
[prev. Lesson]  IsClientConnected & Stray Tasks
     [next Lesson]  Scale: Connection Pooling

The controversy over Nothing by Charles Carroll

Rule #1: All objects created with SET whatever=server.createobject("whatever")
need to be destroyed on that page, i.e.
set whatever=nothing

Rule #2: All objects created with
SET whatever=server.createobject("whatever")
should never be put in a session variable.

These two statements are the source of much controversy. I would like to address the veracity of these statements and address the real truth of this matter and why this truth is important to building high traffic websites. 

The session is issue is dealt with in:
http://www.learnasp.com/freebook/asp/sessionoverview.aspx
http://www.learnasp.com/freebook/asp/globalproblems.aspx
http://www.learnasp.com/freebook/asp/buildvbthreads.aspx
http://www.learnasp.com/freebook/asp/nosessionobjects.aspx

Scenario #1:

set x=server.createobject("whatever.whatever")
....
set x=nothing

Scenario #2

set x=server.createobject("whatever.whatever")
....

In Scenario #1, I can guarantee

  • the object is cleared from memory

  • exactly the line of code where the object is removed from memory

In Scenario #2, I cannot guarantee:

  • that the object WAS cleared from memory
    (I am basing this on a promise in the MS docs, and that the IIS code internally is flawless). IIS is good but if you think it is flawless I would like to ask you to buy some undervalued land in Florida.

  • when the object was cleaned from memory (the docs do not say when garbage collection occurs)

I will also state that large ISPs (Innerhost, DataReturn) will guarantee your webserver will come down several times a day or week with scenario #2 (depending on how many objects are created throughout the day). With Scenario #1 the webserver stays up without incident. This evidence indicates the IIS garbage collection screws up.

Chaz Wish List
Tall Tip $5
Grande Tip $20
Venti Tip $39
Tip Jar Thanks
2004 Thanks
2005 Thanks
HUGE Tip -love site