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

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Nov 10 00:31:36 PST 2009


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


Flament David <flament.david at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #42748|Copie de                    |Unbounded_memory_growth.htm
           filename|bug_memoryLeak.html         |l




--- Comment #2 from Flament David <flament.david at gmail.com>  2009-11-10 00:31:36 PDT ---
(From update of attachment 42748)
<html>
  <head>

   <script language="javascript">

      var containerNode, compteur=0, lastImg, timer, dist=45, number=0;

      function init(){
    var img = new Image();
    img.src = "./resources/"+compteur+".jpg";
    lastImg = img;
    containerNode = document.getElementById("imgContainer");
    containerNode.appendChild(img);
      }

      function start_loop(){
      timer = window.setInterval(function(){
        rLaunch();
      },1);
      }

      function stop_loop(){
      clearInterval(timer);
      }

      function rLaunch(){
    document.getElementById("imgContainer").innerHTML = "";
    lastImg=null;
    dist = dist+1;
    number = number+1;
    var img = new Image();
    compteur = (compteur==12) ? 0 : compteur+1; 
    img.src = "./resources/"+compteur+".jpg?dist="+dist;
    lastImg = img;

    containerNode.appendChild(img);
    document.getElementById("textContainer").innerHTML = "Images loaded : "+
number;
     }

    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();      

     }

  </script>

  <style type="text/css">

    img{
      left:45px;
      top:45px;
      position:absolute;
    }

    .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_loop()">Start_loop</a>
    <a href="#" onclick="javascript:stop_loop()">Stop_loop</a>
    </div>
    <div id="imgContainer"></div>
    <div id="textContainer" class="textContainer"></div>
  </body>
</html>

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list