Setting object to Nothing

Results 1 to 2 of 2

Thread: Setting object to Nothing

  1. #1
    Join Date
    Dec 1969

    Default Setting object to Nothing

    If I don&#039;t set a variable = to an object, will I avoid memory issues?<BR><BR>EXAMPLE:<BR>[code language="VBScript"]<BR>Dim acl, objDB<BR>Set objDB = Server.CreateObject("CS_Database.FXS")<BR>acl = objDB.getExpDateForObj(iID,sComType,iRegType)<BR>S et objDB = Nothing<BR>[/code]<BR><BR>Alternate approach:<BR>[code language="VBScript"]<BR>acl = Server.CreateObject("CS_Database.FXS")<BR>.getExpD ateForObj(iID,sComType,iRegType)<BR>[/code]<BR>

  2. #2
    Join Date
    Dec 1969

    Default Nope...

    The object *still* has to be *both* created and destroyed.<BR><BR>Now, granted, since there is no object reference hanging on to the object after the end of that single statement, you are correct in assuming you don&#039;t have to set anything to Nothing. But setting to nothing is (a) no big deal, (b) not really necessary in most cases [the object *will* get garbage collected when the ASP page is finished], and (c) a good idea despite (a) and (b).<BR><BR>You might want to look at my 3-part series on "Variables and Values in VBSCript" that is up on 4GuysFromRolla. The first part appeared in March, 2001.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts