[Javascript] AJAX app causing excessive browser memory usage

Rick Emery rick at emery.homelinux.net
Thu May 18 21:24:00 CDT 2006


Quoting Matt Warden <mwarden at gmail.com>:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Rick Emery wrote:
>>>> xmlList = null;
>>>
>>> Keep this one.
>>
>> Why wouldn't this, like the others, happen when it fell out of scope
>> (i.e., when the handleELResponse() function exited)?
>
> In your example it looked like this was in global scope.

You're right; mea culpa.

>>> 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.
>>
>>
>> I'm actually not creating a new one every 30 seconds; I create the xhr
>> object when the page first loads, and reuse it every 30 seconds to  send
>> the request (and process the response).
>
> I would suggest not doing this. The object is meant to represent a
> request, not a connection. At minimum, the object and all its request
> and response content must remain in memory indefinitely rather than only
> for x milliseconds while you do your processing. At worst, the designers
> of the object assumed a short lifecycle and coded accordingly.

Okay, I'll buy that :-) I'll try modifying the code so that the object  
gets created on request and destroyed after handling the response.

Thanks,
Rick
-- 
Rick Emery

"When once you have tasted flight, you will forever walk the Earth
  with your eyes turned skyward, for there you have been, and there
  you will always long to return"
                                               -- Leonardo Da Vinci




More information about the Javascript mailing list