<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>24806</bug_id>
          
          <creation_ts>2009-03-25 10:37:43 -0700</creation_ts>
          <short_desc>addEventListener to node with closure+circular ref leaks DOM nodes</short_desc>
          <delta_ts>2009-04-11 12:54:23 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>DOM</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>UNCONFIRMED</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Greg">280lifestyle</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ddkilzer</cc>
    
    <cc>emacemac7</cc>
    
    <cc>ggaren</cc>
    
    <cc>pam</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>115175</commentid>
    <comment_count>0</comment_count>
    <who name="Greg">280lifestyle</who>
    <bug_when>2009-03-25 10:37:43 -0700</bug_when>
    <thetext>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.

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.1//EN&quot;
  &quot;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&quot;&gt;

&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot;&gt;
&lt;head&gt;
  &lt;title&gt;listTest&lt;/title&gt;

  &lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;
				
		makeClosure= function(object) {
		  return function() {
		    return object;
		  }
		};
		
		gIntervalCount = 0;

		myLeakyFunc = function() {		
			var i, widget;
			
			console.log(&quot;myLeakyFunc: &quot;+gIntervalCount++);
			
			for(i=0; i&lt;1000; i++) {
				
				// The leak seems to be caused by an event listener on a node, 
				// where the listener&apos;s closure has a circular reference to the node.
				widget = document.createElement(&apos;div&apos;);
				widget.addEventListener(&apos;whatever&apos;, makeClosure(widget), false);
				
				// Adding some extra chold nodes to the leaked div makes the memory leak more apparent, but is not necessary.
				widget.innerHTML = &apos;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&apos;;				
			}
		}

		window.setInterval(myLeakyFunc, 500);

  &lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115176</commentid>
    <comment_count>1</comment_count>
    <who name="Greg">280lifestyle</who>
    <bug_when>2009-03-25 10:38:17 -0700</bug_when>
    <thetext>Does not leak in Firefox 3.x</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115234</commentid>
    <comment_count>2</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2009-03-25 15:14:03 -0700</bug_when>
    <thetext>Looks like a duplicate of Bug 21260.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116675</commentid>
    <comment_count>3</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2009-04-06 15:10:08 -0700</bug_when>
    <thetext>Geoff, was this fixed by Bug 21260?

http://trac.webkit.org/changeset/42256
</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>