Which is the most memory leak safe approach.

Posted by MattC on Stack Overflow See other posts from Stack Overflow or by MattC
Published on 2010-04-09T11:31:46Z Indexed on 2010/04/09 11:33 UTC
Read the original article Hit count: 445

I have a table of frequently updated information. This is presented using a container div with a div for each row, each row containing 10 divs.

I am using setInterval to call a an asmx webservice that returns some json formatted information.

On the success callback I call $("#myContainer").empty(); on the container div and recreate the rows and 10 nested divs for each row's columns.

This page may be left to run for a whole day, so I am wary of updating the DOM like this as I have noticed that memory does rise for the browser over time (IE8).

The other approach I am considering is to add an idea to the row div. When new results process each item of data, look for the corresponding row, if it exists overwrite the data in each div. If it doesn't exist (new data for example), append the row.

What approaches have others used for this sort of long lived pseudo realtime information display.

TIA

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX