[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ale] Possible javascript memory leak?



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.