Possible Duplicate:
jQuery Memory Leak Suspicion
I noticed our website got slower and slower the longer the tab stayed open. Using Chrome's Task Manager, I narrowed down the problem:
Each time the following line of code is called the memory usage increases:
$jquery.post(url, params);
I implemented this code on a 1second timer, and within a few minutes memory usage had gone from 30MB to 250MB. Commenting out just this one line of code fixes the problem. Note that I only comment out this one line; I still let the URL and params be generated. So the problem is definitely to do with this line of code. Each time it runs about 2MB more of memory is consumed.
Clearly there is some sort of memleak. I expect it has something to do with caching or JSON deserialization of the results (the JSON results are potentially rather large).
Can anybody offer a work-around or solution? Even merely forcing some garbage collection would be acceptable. FWIW, the memory usage does occasionally decrease, though not by much (garbage collection?). I just saw it drop from 300MB to 250MB, but is now inching upward again.
More specifically, the code looks like this...
...
init: function()
{
setInterval(function(){ SManager.updateAll(); }, 1000);
},
updateAll: function()
{
var url = SManager.SERVER_URL;
var params = new Object();
params.version = 1;
params.platform = 'web';
$jquery.post(url, params);
},
Thanks!