我一直在跟踪我的网络应用程序中的内存泄漏,该应用程序动态删除和添加附加了提示提示工具提示的锚点,我认为我可能已将问题缩小到提示提示中的主要闭包,该提示提示将提示提示附加到节点(第 32 行: var link = this, $this = $(this);).
我一直在 SIEV 中使用 jquery 1.3.2 的修改版本运行以下脚本,并进行了以下修复,该修复允许删除线索提示元素。但是,锚节点成为孤立节点,因为在删除线索提示节点后仍有 1 个对它们的引用?
如果我出于测试目的将线索提示源的第 32 行更改为以下内容: var link = $('br'), $this = $('br');
锚被释放,但“br”节点开始建立。
因此,我想知道是否有人知道我如何解决这个问题?或者如果我只是没有正确释放资源?
附加脚本和来源:
jQuery 修改。在第 1247 行之后,在右花括号之前插入以下内容(http://markmail.org/message/cfi4bvfjc3m6ww6k#query:jquery%20memory%20leak%20in%20remove%20and%20empty+page:1+mid:tapc7zt3cwl6rw4f+state:结果):
this.outerHTML = "";
示例脚本:
<html>
<head>
<link rel="stylesheet" type="text/css" href="jquery.cluetip.css"/>
<script type="text/javascript" src="jquery-1.3.2.js"></script>
<script type="text/javascript" src="jquery.cluetip.js"></script>
<script type="text/javascript">
$(document).ready(function() {
setInterval(resetCluetip, 1000);
});
function resetCluetip() {
$('a').each(function() {
$(this).cluetip('destroy');
$(this).unbind().remove();
});
$('#cluetip*').unbind().empty();
$('body').html('<a href="#" class="contextMenu" title="title|body">anchor one</a><br>');
$('a').each(function() {
$(this).cluetip({splitTitle: '|'});
});
}
</script>
</head>
<body>
</body>
</html>