ASP JavaScript: Garbage collection algorithm

Discussion in 'ASP General' started by Benjamin Johnston, Nov 30, 2005.

  1. Hi,

    I've found lots of discussion about the JavaScript garbage collector,
    but no clear answer to this question:

    Is the garbage collection algorithm used in JavaScript on ASP based on
    reference counting or tracing?


    Thanks for your help,

    (I'm planning on creating some user defined Objects with lots of cyclic
    references (e.g., a.next.prev = a), and would like to know if this will
    cause a problem for the garbage collector. The fact that garbage
    collection in general isn't instantaneous suggests to me that it isn't
    based on reference counting, but I just want to be sure.)

    (I'm NOT using ASP.NET... just plain old ASP... if this is relevant)

    -Benjamin Johnston
     
    Benjamin Johnston, Nov 30, 2005
    #1
    1. Advertisements

  2. Benjamin Johnston wrote:
    > Hi,
    >
    > I've found lots of discussion about the JavaScript garbage collector,
    > but no clear answer to this question:
    >
    > Is the garbage collection algorithm used in JavaScript on ASP based on
    > reference counting or tracing?
    >

    There's nothing better than Eric Lippert's blogs on this subject:
    http://blogs.msdn.com/ericlippert/
    Specifically:
    http://blogs.msdn.com/ericlippert/archive/2003/09/17/53038.aspx
    http://blogs.msdn.com/ericlippert/archive/2004/04/28/122259.aspx
    >
    > (I'm planning on creating some user defined Objects with lots of
    > cyclic references (e.g., a.next.prev = a), and would like to know if
    > this will cause a problem for the garbage collector.


    Probably. Read what Eric has to say about closures.
    http://blogs.msdn.com/ericlippert/archive/2003/09/17/53028.aspx


    --
    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"
     
    Bob Barrows [MVP], Dec 1, 2005
    #2
    1. Advertisements


  3. > > Is the garbage collection algorithm used in JavaScript on ASP based on
    > > reference counting or tracing?

    /snip/
    > http://blogs.msdn.com/ericlippert/archive/2003/09/17/53038.aspx
    > http://blogs.msdn.com/ericlippert/archive/2004/04/28/122259.aspx


    Fantastic, thanks a lot! This is exactly what I was looking for.


    For the benefit of other readers and future readers searching the
    archives, I'll summarize:

    JavaScript in ASP uses a mark-and-sweep tracing garbage collector, so
    it is okay to have cyclic **user-defined** data structures.

    However, the garbage collector can't detect cycles involving
    non-JavaScript objects (such as mixed VBScript and JavaScript, or
    built-in objects, or COM objects); so such cycles will not be garbage
    collected.

    Also, it should be noted that this only applies to JavaScript, VBScript
    uses a different garbage collector that doesn't handle cycles.

    -Benjamin Johnston
     
    Benjamin Johnston, Dec 2, 2005
    #3
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Laser Lu

    Garbage Collection and Manage Code?

    Laser Lu, Jan 26, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    935
    Gaurav Khanna [C# MVP]
    Jan 27, 2004
  2. Cheung, Jeffrey Jing-Yen
    Replies:
    3
    Views:
    1,805
    Cheung, Jeffrey Jing-Yen
    Jul 10, 2003
  3. IDoNothing

    Garbage Collection in ASP.NET

    IDoNothing, Jan 9, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    8,564
    cjohn
    Aug 20, 2009
  4. =?Utf-8?B?RnJhbms=?=

    ASP.NET Session State Server and garbage collection

    =?Utf-8?B?RnJhbms=?=, Jan 29, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    3,943
    Alvin Bruney [MVP]
    Jan 31, 2004
  5. Dylan
    Replies:
    5
    Views:
    584
    Daniel T.
    Mar 22, 2005
  6. Kevin Jackson

    ASP.NET 1.1 garbage collection

    Kevin Jackson, May 19, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    583
    Kevin Jackson
    May 19, 2006
  7. Replies:
    1
    Views:
    602
    mrstephengross
    Jul 25, 2005
  8. Øyvind Isaksen
    Replies:
    1
    Views:
    1,253
    Øyvind Isaksen
    May 18, 2007
Loading...