Page-level If you have page-level objects and are running IIS 4.0, they are not released at the point in the page where you issue the following command:
<% set object = nothing %> |
Page-level objects are NOT released until the page goes out of scope. And, according to many reports, the memory is not released completely if the object is *not* explicitly destroyed, as per above.
IIS 5.0 and greater are reportedly much better at cleaning up the memory used by COM objects. Since it releases the object THE INSTANT you set it to nothing, there is suddenly a great advantage to doing so explicitly as early as possible in the code. In other words, create late, destroy early.
Session-level Session-level objects, unless you explicitly release them from the session yourself, are (allegedly) destroyed when the session ends. This depends on how the session ends, of course. See
Article #2078 for more information about how reliable Session_OnEnd() can be.
There are very few scenarios where you should be using objects in session variables (see
Article #2053). In about 99% of all cases, objects should be created and destroyed at the page level.