html5 - Long-running JavaScript Web -
i making website contains html5 , javascript, website requires few user interactions (only @ start), after web display kind of informations (text, time, pictures, etc)
in website use timer (setinterval) @ specified intervals (3seconds or 20seconds), first 2 hours, runs fine, after that, crash browser or make hang, wonder if using setinterval idea
i clear interval (with clearinterval) if want change interval activate again. need web run days or weeks, if it's not hang, cause browser(not whole pc) run slow,
so idea use setinterval , clearinterval in long run? or should switch settimeout instead (or same)?
if cause memory leak, cause?
var element=document.getelementbyid("image1"); //it div element var image=new image(); image.src=url; // url path specific image(blob or external source) image.onload=function(){ //basically element.style.backgroundimage = "url(" + url + ")"; element.style.width=image.width.tostring()+"px"; //set original size element.style.height=image.height.tostring()+"px"; //by end of function don't clear variable image image=null };
i found it! apparently not because of image , dom creation handle them correctly after closure, because after changing of dom element, attach event-handler object jquery ($(element).bind(eventhandler,thehandler);)
i thought when attach event bind, replace handler, apparently stack og handlers attached new one. now, once or unbind old 1 if necessary
Comments
Post a Comment