Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Setting ASP object variables to Nothing

Reply
Thread Tools

Setting ASP object variables to Nothing

 
 
mjkahn
Guest
Posts: n/a
 
      05-30-2005
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.

 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      05-30-2005
mjkahn wrote:
> 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/ar...28/122259.aspx

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
re module: Nothing to repeat, but no sre_constants.error: nothing torepeat ? Devin Jeanpierre Python 2 02-14-2012 01:33 PM
Put variables into member variables or function variables? tjumail@gmail.com C++ 9 03-23-2008 04:03 PM
Setting object to Nothing Ven ASP General 2 01-06-2006 04:33 PM
Setting object = nothing after Response.end dotnettester ASP General 6 09-13-2005 06:21 PM
setting to Nothing Mark Kamoski ASP .Net 1 08-07-2003 10:58 PM



Advertisments