DOM memory disposal question

L

Lee

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

Bob Barrows [MVP]

Lee said:
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.
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top