[ale] Possible javascript memory leak?

Jim Lynch ale_nospam at fayettedigital.com
Thu May 3 06:51:44 EDT 2012


I'm running a  small javascript script using the setInterval function.  
Under both Chrome and FF it leaks memory, or at least it keeps consuming 
memory until the system crashes, or freezes up.

Here's the script.

$(document).ready(function()
{
     var refreshId = setInterval( function()
     {
         var r = (-0.5)+(Math.random()*(100));
         console.log(r);
         $('#img-container').attr('src','img.php?h='+r);
     }, 3000);
});

Is there something wrong with it?  Any suggestions on how to cure the 
problem without restarting the browser?  The php code reads a .png file, 
adds a bit of text to it and outputs it so it is displayed.

Thanks,
Jim.


More information about the Ale mailing list