[Javascript] AJAX app causing excessive browser memory usage
Matt Warden
mwarden at gmail.com
Thu May 18 19:21:44 CDT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Rick Emery wrote:
> var xmlList = xhr.responseXML;
Where is the code which handles the AJAX request? That's the most likely
place for a memory leak. And then let us see the code that handles
readystate change, too.
> tdPriority = null;
...
> tdType = null;
...
> trow = null;
These aren't helping you at all, so don't bother. The equivalent happens
when the variables fall out of scope.
> tmpBody = document.getElementById("eltable").replaceChild(tbody,
> oldBody);
If you don't need the result of the right hand side, then don't assign
it to a variable.
> xmlList = null;
Keep this one.
> 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.
Well you're creating a new XHR object every 30 seconds. Not a problem if
you're handling its destruction properly, but I have a hunch you are not.
But we need to see that code.
In the meantime, do yourself a favor and download Drip:
http://outofhanwell.com/ieleak/index.php?title=Main_Page
- --
Matt Warden
Oxford, OH, USA
http://mattwarden.com
This email proudly and graciously contributes to entropy.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFEbQ+YrI3LObhzHRMRAoUEAJ4uUeK5fnJgECcFy0PJLI56/ieVJwCfTv6/
UhuYWkggdV6DwwWY4ZRdDME=
=fuh9
-----END PGP SIGNATURE-----
More information about the Javascript
mailing list