DOM memory disposal question

Discussion in 'ASP General' started by Lee, Jan 13, 2006.

  1. Lee

    Lee Guest

    Hi there,

    Not sure if this is the most relevent newsgroup so please redirect me if
    needed.

    I just have a general query regarding how memory disposal works in relation
    to the DOM object model. Take a look at the pseudo code below.

    Dim odom as domdocument
    dim onode as node
    dim onodeclone as node
    dim onodes as nodelist

    odom = createobject

    onode = selectsinglenode("/blah")
    onodes = selectnodes("//blah")
    onodeclone = onode.clone

    Now, its a given that the odom object needs to be set to nothing but what
    else does, if anything? My understanding is the following: -

    The onode object will just hold a memory reference to somewhere in the odom
    memory space.

    onodes will store an array/arraylist of these memory references

    onodeclone will have its own memory and contain a replica of the data stored
    in the memory location referenced by onode.

    So saying that, which of the above would I have to dispose of too? Are
    onode and onodes taken care of when you dispose of the odom object? I am
    guessing you would have to dispose of onodeclone since it has its own memory?

    Maybe there is a web resource which explains this in detail?

    Thanks in advance.
    Lee, Jan 13, 2006
    #1
    1. Advertising

  2. Lee wrote:
    > Hi there,
    >
    > Not sure if this is the most relevent newsgroup so please redirect me
    > if needed.
    >
    > I just have a general query regarding how memory disposal works in
    > relation to the DOM object model.


    You mean the XMLDOM model?

    > Take a look at the pseudo code
    > below.

    <snip>
    > Now, its a given that the odom object needs to be set to nothing but


    Not really. The garbage collector will do it for you. Oh, sure, if you have
    a large domdocument, and your page has other processing to do, it could be
    beneficial to release it early, but if your page is finished processing,
    there is no need to do anything else.

    Now if you were talking about an ADO Recordset, I would have a different
    answer: there have been memory leaks reported as a consequence of failing to
    close and destroy recordsets prior to closing and destroying the connections
    used to open them. This does not apply to xml domdocuments

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

    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Jan 13, 2006
    #2
    1. Advertising

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. cameron

    DirectoryEntry Disposal Test

    cameron, Apr 13, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    504
    Willy Denoyette [MVP]
    Apr 14, 2004
  2. Roger Twomey
    Replies:
    3
    Views:
    751
    Chris R. Timmons
    Feb 18, 2005
  3. TCORDON

    DataSet Disposal

    TCORDON, Mar 22, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,565
    JiangZemin
    Mar 23, 2005
  4. ASP.NET Object Disposal

    , Aug 20, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    409
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Aug 21, 2006
  5. patrick

    disposal of object

    patrick, Dec 20, 2007, in forum: Java
    Replies:
    3
    Views:
    327
    Thomas Kellerer
    Dec 20, 2007
Loading...

Share This Page