I've modeled some code after the final refactored "net.ContentLoader" in Chapter 9 of "Ajax In Action" for a "Status Application" that I'm building for use within a closed network. I'm seeing a bad slowdown in Mozilla 1.7 and Firefox 2.0 for Sun Solaris 10 using prstat; CPU usage goes to 10~15% and stays there while the browser slows to a crawl after a couple hours with the main page open. I also see a nasty memory leak accumulate ~500K at a time using XP's task manager through Netscape 7.1. These leaks total up to hundreds of MBs eventually. I also have no need to support IE, so most, if not all of the results of google searches have produced no help.
I'll include my js Ajax object and the specific code from ContentLoader causing the leak; specifically the onreadystatechange anonymous function closure) below. The catch to the accumulation of the leak is that I am using setTimeout to call the initialize function once every second. I need to do this in order to display the latest status of the following on my main page: 9 "red/green" status fields, 5 dynamic text fields with status colors, and a large table's html text being built in the php get script of the XHR request. I have several other pages in my site that use Ajax, but this main page is the best example since it has the most updating going on.
Thanks for any help! ~Cory
posted 13 years ago
One quick extra note:
I made some changes to the code last night to move the "new XHR()" object creation to within the ContentLoader's "constructor" call so that I only get one XHR object per item being updated on my main page and the page still leaks like a sieve.
Are you positive the leak is in the Ajax code and not in the code that you are using when the response comes back?
posted 13 years ago
I've tried setting any and all vars declared to null. I've also tested with a very simple div that I'm filling with the current time fetched from MySQL on the server and I see it still leak, albeit a lot less, but still consistently on each update.
Update, I'll post the updating code example for the big table:
[ May 01, 2007: Message edited by: Cory Lancaster ]
It's exactly the same and completely different as this tiny ad: