I use the following pattern that skips memory in Firefox:
$(function() { (function() { var callee = arguments.callee; $.ajax({ url: '...', success: function() { ... setTimeout(callee, 1000); }, error: function() { ... setTimeout(callee, 1000); } }); })(); });
A memory leak persists even when a success / error does nothing but call setTimeout again. I observe a leak through the Windows task manager; if the page is left open, firefox.exe memory usage is slowly increasing. For the final version of this code, I only need to update once a minute, but once a second it shows a memory leak faster!
(Note: this seems like a very similar problem for this question , but the selected answer there does not seem to be suitable for Firefox)
jquery firefox memory-leaks
Bobby jack
source share