Thursday, 5 September 2013

jQuery on-screen clock memory leak

jQuery on-screen clock memory leak

I have the following which is updating an element on the screen, and I
can't seem to prevent it from consuming memory, it is consuming roughly
0.10% or ram every minute.
I have already tried to null all of the variables, but nothing I seem to
do will stop this leak.
function TimeTick(){
var lt = new Date();
lt.setMilliseconds(lt.getMilliseconds()-g_svros);
var ch=lt.getHours(), cm=lt.getMinutes(), cs=lt.getSeconds();
if(ch==0) ch=12;
$('#clock').val((ch
>12?ch-12:ch)+":"+(cm<10?"0":"")+cm+":"+(cs<10?"0":"")+cs+"
"+(ch>=12?"PM":"AM"));
lt=null;ch=null;cm=null;cs=null;
}
var tick = setInterval('TimeTick()',250);

No comments:

Post a Comment