[Webkit-unassigned] [Bug 24806] New: addEventListener to node with closure+circular ref leaks DOM nodes
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Mar 25 10:37:44 PDT 2009
https://bugs.webkit.org/show_bug.cgi?id=24806
Summary: addEventListener to node with closure+circular ref leaks
DOM nodes
Product: WebKit
Version: 528+ (Nightly build)
Platform: All
OS/Version: All
Status: UNCONFIRMED
Severity: Normal
Priority: P2
Component: HTML DOM
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: 280lifestyle at gmail.com
The following JS leaks DOM nodes until the document is thrown away. Safari 4,
also tested with Chrome 1.x/v8 which shows the same behavior.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>listTest</title>
<script type="text/javascript" charset="utf-8">
makeClosure= function(object) {
return function() {
return object;
}
};
gIntervalCount = 0;
myLeakyFunc = function() {
var i, widget;
console.log("myLeakyFunc: "+gIntervalCount++);
for(i=0; i<1000; i++) {
// The leak seems to be caused by an event
listener on a node,
// where the listener's closure has a circular
reference to the node.
widget = document.createElement('div');
widget.addEventListener('whatever',
makeClosure(widget), false);
// Adding some extra chold nodes to the leaked
div makes the memory leak more apparent, but is not necessary.
widget.innerHTML =
'<div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>';
}
}
window.setInterval(myLeakyFunc, 500);
</script>
</head>
<body>
</body>
</html>
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the webkit-unassigned
mailing list