jquery - Javascript Memory Usage -


in following code:

$(document).ready(function() {     var content = "";     (var = 0; < 1000; i++) {         content += "<div>testing...</div>";     }     $("#load").click(function() {         $("#mydiv").empty();         $("#mydiv").append(content);         return false;     }); }); 

load simple link , mydiv simple div. in each major browser tested in, when click on link multiple times, see memory usage go in task manager. in ie, goes each time , stays up. in ff, goes each time, once in while comes down (i think means memory being reclaimed or garbage collected - sign). in chrome, goes each time , stays up.

first, code cleaning dom correctly? if so, why memory usage increase every click?

note: tried make example simple possible, similar problem having in app.

wrap around div tag. immensely , use native innerhtml (its faster).

$(document).ready(function() {      var content = "";      (var = 0; < 1000; i++) {          content += "<div>testing...</div>";      }      $("#load").click(function() {          document.getelementbyid('mydiv').innerhtml = ('<div>'+content+'</div>');          return false;      });  });  

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -