[Webkit-unassigned] [Bug 31253] Unbounded memory growth when adding and removing images

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Feb 16 23:02:39 PST 2015


https://bugs.webkit.org/show_bug.cgi?id=31253

--- Comment #13 from Makivelli <onekey247 at gmail.com> ---
Comment on attachment 42748
  --> https://bugs.webkit.org/attachment.cgi?id=42748
bug_memoryLeak.html

><html>
>  <head>
>
>   <script language="javascript">
>
>      var containerNode, compteur=0, lastImg, timer, dist=45, number=0;
>      var activateGfx = false;
>      var activateOpacity = false;
>
>      function init(){
>	var img = new Image();
>	img.src = "./resources/"+compteur+".jpg";
>	lastImg = img;
>	containerNode = document.getElementById("imgContainer");
>	containerNode.appendChild(img);
>      }
>
>      function start(){
>	  timer = window.setInterval(function(){
>	    rLaunch();
>	  },1);
>      }
>
>      function stop(){
>	  clearInterval(timer);
>      }
>
>      function rLaunch(){
>	document.getElementById("imgContainer").innerHTML = "";
>	//lastImg.style.right=dist+"px";
>	lastImg=null;
>	dist = dist+1;
>	number = number+1;
>	//lastImg.style.left="auto";
>	var img = new Image();
>	compteur = (compteur==12) ? 0 : compteur+1; 
>	var str = activateGfx ? "|com.motorola.gfxmem=true":"";
>	img.src = "./resources/"+compteur+".jpg?dist="+dist+str;
>	lastImg = img;
>	
>	containerNode.appendChild(img);
>	var desc = activateOpacity ? " opacity activated" :  "";
>	document.getElementById("textContainer").innerHTML = "NbImages chargees : "+ number + desc;
>     }
>
>    function clean(){
>      document.getElementById("imgContainer").innerHTML = "";
>      number = 0;
>      clearInterval(timer);
>	  
>	  // add by DFL
>	while(containerNode.hasChildNodes()) {
>	containerNode.removeChild(containerNode.lastChild) ;
>	}
>	
>	 // Remove element nodes and prevent memory leaks
>	 jQuery(this).children().remove();
>	 // Remove any remaining nodes
>	 while (this.firstChild)
>	 this.removeChild(this.firstChild);	
>	 
>	 containerNode.clear();
>	 containerNode.empty();	  
>	  
>     }
>
>    function activOpacity(){
>	 activateOpacity = !activateOpacity;
>	  if(activateOpacity) {
>	      document.getElementById("imgContainer").className = "opacity";
>	      document.getElementById("isOpacityActivated").innerHTML = "(on)";		
>	  } else {
>	      document.getElementById("imgContainer").className = "";
>	      document.getElementById("isOpacityActivated").innerHTML = "(off)";		
>	  }
>
>	clean();
>    }
>  </script>
>
>  <style type="text/css">
>
>    img{
>      left:45px;
>      top:45px;
>      position:absolute;
>     /* opacity:0.5;*/
>    }
>
>    .opacity img{
>	opacity:0.5;
>     }
>
>    div.controls{
>      position:absolute;
>      bottom:20px;
>      left:45px;
>
>    }
>
>    div.textContainer{
>      position:absolute;
>      top: 150px;
>      left: 400px;
>    }
>
>
>  </style>
>
>
>  </head>
>  <body onload="init()">
>    <div id="controls" class="controls">
>	<a href="#" onclick="javascript:start()">Start</a>
>	<a href="#" onclick="javascript:stop()">Stop</a>
>	<a href="#" onclick="javascript:activOpacity()">Opacity <span id="isOpacityActivated">(Off)</span></a>
>    </div>
>    <div id="imgContainer"></div>
>    <div id="textContainer" class="textContainer"></div>
>  </body>
></html>

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20150217/8d415701/attachment-0002.html>


More information about the webkit-unassigned mailing list