469,578 Members | 1,699 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,578 developers. It's quick & easy.

Objects set to nothing

Hi,
anyone have better information on IIS 5.0 memory behaviour
on setting objects to nothing?

Connections and recordsets of course should be set to
nothing, but should for example XMLNode object be set to
nothing?

Thanks, Tony

Jul 19 '05 #1
1 5213
Setting to Nothing is a bit of a misnomer in that as soon as the current ASP
page goes out of scope (eg. has completed processing) then all objects are
contacted and told to destroy themselves anyway.
It is true that in a stateful environment such as a classic VB application
that not setting global and module level objects to Nothing can have an
adverse effect on memory usage since those objects may remain in scope (and
thus in memory) for a lot longer than anticipated.
I have seen a classic example of this in my own application working with a
mail archive (1000+ mails). I enumerated them to a collection and held a
mail COM object for each. I forgot to set the object to nothing as I was
running through the collection collecting the header information resulting
in a dramatic rise in memory to over 500Mb. When I realised the mistake and
then set each mail object to nothing after I had finished with it then the
memory remained static at < 2Mb.
However, in ASP, only application and session objects [not strictly true -
see later] persist beyond the scope of a single ASP page being processed and
so the issue of 'managing' the objects lifetime becomes moot....as the page
completes then all objects go out of scope automatically.
There is a situation in which setting to Nothing must be done [in fact you
need to call the relevant .Quit method first] ... when working with
ActivexEXE Servers. These objects create out of process copies of certain
public classes that can be made to persist outside the scope of a page. This
is due to the fact that the class object is referenced by the ActivexEXE
Server, not the ASP page. A good example is instantiating an instance of
Excel in an ASP page and not calling .Quit on it before the page completes
..... Excel will remain active and in memory but divorced from all efforts to
communicate with it. Excel is in fact an ActivexEXE Server as is Word, etc.
That's one of the main issues with trying to use Excel server-side in a web
environment, it has the capability to eat up all the server memory if you
get it wrong.

My apologies if I get anything slightly mis-quoted, it's a bit of a
contentious subject with IIS and I'm not an MVP (although I'd like to be at
some point if I can ever find the time to do the exams etc.).

Hope this helps,

Chris.

"Tony" <an*******@discussions.microsoft.com> wrote in message
news:02****************************@phx.gbl...
Hi,
anyone have better information on IIS 5.0 memory behaviour
on setting objects to nothing?

Connections and recordsets of course should be set to
nothing, but should for example XMLNode object be set to
nothing?

Thanks, Tony
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by vvenk | last post: by
161 posts views Thread by KraftDiner | last post: by
41 posts views Thread by =?Utf-8?B?VGltIE1hcnNkZW4=?= | last post: by
29 posts views Thread by Jerry Spence1 | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.