[Javascript] AJAX app causing excessive browser memory usage
Paul Novitski
paul at juniperwebcraft.com
Thu May 18 18:41:32 CDT 2006
At 04:12 PM 5/18/2006, Rick Emery wrote:
>I have a web application in which the data in a table is refreshed
>every 30 seconds. I'm using AJAX to get the data.
...
> tmpBody = document.getElementById("eltable").replaceChild(tbody, oldBody);
...
>In both Internet Explorer and Firefox, I can see that, each time the
>xhr response is received and the data updated, the memory consumption
>of the browser process increases. I expect this if the new table body
>has more rows than the old table, but it happens even when there are
>fewer rows. If I let it run over the weekend, it will eventually
>consume all of the available memory of the machine. Closing the
>browser is the only way to free the memory.
I wonder if it's replaceChild that's the culprit. Have you tried
using removeChild and appendChild instead?
I also wonder whether it has to do with replacing a parent element
that has child nodes. If so, it might help to walk the DOM removing
all the children within the table body before removing or replacing it.
I just got 155,000 hits by googling [ajax memory leak] and 78 hits
for [ajax memory leak replacechild], so you might find answers out
there on the net.
Paul
More information about the Javascript
mailing list