Andrew said:
If I'm using DOM methods to dynamically create elements in a
page is it necessary for me to clear whatever variables I used
to create the elements when the page unloads? I'm reading bits
and pieces which seems to indicate that they'll be memory issues
if I don't.
Javascript uses automatic garbage collection and should free memory when
pages unload. There is, however, a running problem with IE browsers. If
_circular_ references are constructed between ECMAScript native objects
and DOM/COM objects then IE's garbage collection cannot recognise when
it is appropriate to free those objects. This can result in memory
leaks, but the references have to be circular before this is an issue.
One of the strategies for dealing with this problem is to break circular
references onunlod. Others include never creating such references or
breaking such references at the end of functions that create them.
Javascript closures are the most common source of problematic circular
references between javascript objects and DOM/COM objects (the c.l.js
FAQ includes an article on closures with some coverage of the memory
leak problem).
Richard.