memory leak using html() method

memory leak using html() method


Hi everyone,
I'm experiencing memory leak in my extranet application. I perform an
ajax call every couple of seconds to retrieve an xml document which I
then transform into an html table using xsl (client-side) and I put
the result into a div. Otherwise I'm not doing anything fancy. I've
included some sample code below.
The memory leak occurs on the code line "$
("#tableHere").html(transform);" in both Firefox 2.0.0.13 and IE
6.0.2900. I am using the latest version of jquery (1.2.3).
I read Fabien Meghazi's thread from 4-Mar-08, where he describes a
somewhat similar problem. Link :
http://groups.google.com/group/jquery-dev/browse_thread/thread/4c0778bb9d369076
However, unlike him I am not using events (at least not yet), I am
using the latest version of jquery, and the problem occurs on both IE
and FF.
I tried to install the latest IE updates from MSFT, but to no avail.
http://support.microsoft.com/kb/929874/
I added a call to console.log() in the jquery remove() method to see
if the old table was actually being deleted during each refresh, and
indeed this seems to be the case; see the output from firebug below.
I am at my wits end with this, if anyone of the list readers would be
kind enough to comment I would be deeply appreciative.
Yours truly,
Patrick Collins
Firebug output :
GET http://localhost/?get=Data&_=1207300824109 (266ms)jquery.js (line
2774)
Remove() <thead>
Remove() <tr>
Remove() <th>
Remove() <th>
Remove() <tfoot>
continues...
Remove() <td>
Remove() <table id="busgrid" class="tablesorter" cellspacing="1">
Javascript sample code :
var xsl = null;
$(function() {
$.ajax({type: "GET",
url: "/xsl/table.xsl",
dataType: "xml",
cache: false,
success: function(res){
xsl = res;
RefreshTable();
}});
});
function RefreshTable()
{
$.ajax({type: "GET",
url: "/?get=Data",
dataType: "xml",
cache: false,
success: function(res){
transform = $.xslt({xml:res, xsl:xsl});
$("#tableHere").html(transform);
setTimeout("RefreshTable()", 5000);
}});
}
html sample code :
<div id="tableHere">
</div>
xsl sample code :
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<table cellspacing="1" >
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Footer 1</th>
<th>Footer 2</th>
</tr>
</tfoot>
<tbody>
<xsl:for-each select="NewDataSet/Buses">
<tr>
<td>
<xsl:value-of select="@ID"/>
</td>
<td>
<xsl:value-of select="@Active"/>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</xsl:template>
</xsl:stylesheet>
xml sample :
<NewDataSet>
<Buses ID="823" Active="Inactif" />
<Buses ID="822" Active="Inactif" />
continues...
</NewDataSet>