objects as function return values

Results 1 to 2 of 2

Thread: objects as function return values

  1. #1
    Join Date
    Dec 1969

    Default objects as function return values

    I&#039;m passing an object back from a function which happens to be in a windows script component.<BR><BR>I&#039;d like to know how expensive an operation this is.. is it better to work around it if possible?<BR><BR>I guess the root of the problem is that in the function that sets an object as a return value, I can&#039;t end with a Set xxxx = Nothing because I&#039;ll end up passing back Nothing. That means I&#039;m always Setting an object and never freeing up the memory by returning it to Nothing.<BR><BR>dummy code eg:<BR>IN THE CALLING SCRIPT:<BR><BR> Set DictionaryObject = Server.CreateObject(myWSC.test)<BR> Set ANewDictionary = DictionaryObject.CreateDictionary()<BR><BR> .... some code ...<BR><BR> Set ANewDictionary = Nothing<BR> Set DictionaryObject = Nothing<BR><BR>&#039; variables are returned to nothing<BR><BR><BR>IN THE WSC COMPONENT:<BR>function CreateDictionary()<BR> Set CreateDictionary = Server.CreateObject("Scripting.Dictionary")<BR><BR > CreateDictionary.Add "myKey1", "Bob"<BR> CreateDictionary.Add "myKey2", "Fred"<BR><BR>&#039; can&#039;t set CreateDictionary to Nothing!<BR>end function<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: objects as function return values

    I think that once the script is done executing, any garbage is picked up and cleared away.

Posting Permissions

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