2

We found a serious memory leak on IE when doing DOM manipulation. Basically, we were doing this:

function updateTable(){
    $.get('table.jsp', {}, function(data){
        $('#dataTableContainer').empty().html($(data).find('#dataTable'));
        setTimeout(updateTable, 1000);
    });
}

and repeating that method once every second. From what we were able to see, that method was leaking around 1Mb of memory every 10 seconds with the jQuery 1.7.1 (it was even worse with older versions).

Are we doing something wrong? We tried several solutions already published in stackoverflow (Ex. jQuery memory leak with DOM removal) but none worked.

Community
  • 1
  • 1
rreyes1979
  • 1,855
  • 3
  • 23
  • 34

1 Answers1

0

Try this:

function updateTable(){
    $.get('table.jsp', function(data){
        var dt = $(data).find('#dataTable').html()
        $('#dataTableContainer').html(dt);
        setTimeout(updateTable, 1000);
    });
}

The html jQuery method receives a string or a function, NOT a query object like you are doing. The html method replaces the content, so there is no need for using the empty method.

Ivan Castellanos
  • 8,041
  • 1
  • 47
  • 42