<?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>29093</bug_id>
          
          <creation_ts>2009-09-09 10:29:58 -0700</creation_ts>
          <short_desc>[V8] HTML attribute listeners leak memory.</short_desc>
          <delta_ts>2014-12-16 00:48:28 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore Misc.</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</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="Vitaly Repeshko">vitalyr</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>dglazkov</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>145824</commentid>
    <comment_count>0</comment_count>
    <who name="Vitaly Repeshko">vitalyr</who>
    <bug_when>2009-09-09 10:29:58 -0700</bug_when>
    <thetext>[V8] HTML attribute listeners leak memory.

Creating DOM elements using innerHTML with listeners will leak memory in case these listeners are invoked at least once.

function leak() {
  var node = document.createElement(&quot;span&quot;);
  node.innerHTML = &quot;&lt;span onclick=&apos;&apos;&gt;&lt;/span&gt;&quot;;
  node.childNodes[0].onclick();  // (*)
}

If you remove (*) line everything is back to normal. The cycle looks like this:

  C++ Span Element &lt;---------------------- JS node wrapper
        |                                        ^
        v                                        |
V8LazyEventListener --[strong handle]--&gt; JS function (onclick)

The reference between JS function and JS wrapper gets created in V8LazyEventListener when it lazily compiles the function. This is very similar to http://crbug.com/17400 but with a different C++ listener type.

This can be fixed like http://crbug.com/17400 by making the handle in V8LazyEventListener weak and adding a hidden dependency from JS wrapper to JS function to prevent the function from being collected.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>145826</commentid>
    <comment_count>1</comment_count>
      <attachid>39277</attachid>
    <who name="Vitaly Repeshko">vitalyr</who>
    <bug_when>2009-09-09 10:32:07 -0700</bug_when>
    <thetext>Created attachment 39277
Test page to demonstrate the leak.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1055951</commentid>
    <comment_count>2</comment_count>
    <who name="Brian Burg">burg</who>
    <bug_when>2014-12-16 00:48:28 -0800</bug_when>
    <thetext>Closing some V8-related work items.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>39277</attachid>
            <date>2009-09-09 10:32:07 -0700</date>
            <delta_ts>2009-09-09 10:32:07 -0700</delta_ts>
            <desc>Test page to demonstrate the leak. </desc>
            <filename>leak.html</filename>
            <type>text/html</type>
            <size>335</size>
            <attacher name="Vitaly Repeshko">vitalyr</attacher>
            
              <data encoding="base64">PGh0bWw+CjxoZWFkPgo8L2hlYWQ+Cjxib2R5Pgo8c2NyaXB0PgpmdW5jdGlvbiBsZWFrT25lKCkg
ewogIHZhciBub2RlID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic3BhbiIpOwogIG5vZGUuaW5u
ZXJIVE1MID0gIjxzcGFuIG9uY2xpY2s9Jyc+PC9zcGFuPiI7CiAgbm9kZS5jaGlsZE5vZGVzWzBd
Lm9uY2xpY2soKTsKfQpmdW5jdGlvbiBsZWFrKCkgewogIGZvciAodmFyIGkgPSAwOyBpIDwgMTAw
MDA7ICsraSkgbGVha09uZSgpOwp9Cjwvc2NyaXB0PgoKPGlucHV0IHR5cGU9ImJ1dHRvbiIgdmFs
dWU9IkxlYWsgTW9yZSIgb25jbGljaz0ibGVhaygpIj4KCjwvYm9keT4KPC9odG1sPgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>