[Javascript] AJAX app causing excessive browser memory usage

Rick Emery rick at emery.homelinux.net
Tue May 23 11:30:38 CDT 2006


Quoting Matt Warden <mwarden at gmail.com>:

> Rick Emery wrote:
>> 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.

Changing this fixed the memory issues. Instead of creating one  
xmlhttprequest object and using it for the life of the application, I  
now create one when I need to make a request and destroy it after the  
response is handled. For some reason that I don't understand, my  
memory issues are gone and usage is steady for the life of the session.

Thanks!! (I'm not one for excessive use of puncuation, but felt like  
this deserved more than one exclamation point :-)

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