Setting ASP object variables to Nothing

M

mjkahn

Folks,

I have some ASP pages that contain code like this:

dim foo
set foo = Server.CreateObject("myDLL.myObject")
foo.CallAMethod

Is it important that I "set foo = Nothing" before each ASP page ends? If I
don't set foo to nothing, will the memory it uses be freed automatically when
the ASP page ends?

Some information that might help:
- IIS 5.0
- Windows 2000 Server
- myDLL is a custom Visual Basic 6 DLL (apartment threaded)

Thanks very much!

MJ.
 
B

Bob Barrows [MVP]

mjkahn said:
Folks,

I have some ASP pages that contain code like this:

dim foo
set foo = Server.CreateObject("myDLL.myObject")
foo.CallAMethod

Is it important that I "set foo = Nothing" before each ASP page ends?
If I don't set foo to nothing, will the memory it uses be freed
automatically when the ASP page ends?

The answer is a qualified "yes". As long as there is nothing preventing the
object from being destroyed, then it will be automatically destroyed when
the last reference to the object goes out of scope.

http://blogs.msdn.com/ericlippert/archive/2004/04/28/122259.aspx

Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top