<?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>139812</bug_id>
          
          <creation_ts>2014-12-19 00:35:39 -0800</creation_ts>
          <short_desc>REGRESSION(176609): Very high memory usage in Canvas/reuse.html performance test</short_desc>
          <delta_ts>2015-02-04 07:37:51 -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>New Bugs</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P1</priority>
          <bug_severity>Critical</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>139140</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Csaba Osztrogonác">ossy</reporter>
          <assigned_to name="Chris Dumez">cdumez</assigned_to>
          <cc>barraclough</cc>
    
    <cc>cdumez</cc>
    
    <cc>cgarcia</cc>
    
    <cc>clopez</cc>
    
    <cc>commit-queue</cc>
    
    <cc>dino</cc>
    
    <cc>ggaren</cc>
    
    <cc>gyuyoung.kim</cc>
    
    <cc>jonlee</cc>
    
    <cc>kling</cc>
    
    <cc>ossy</cc>
    
    <cc>rniwa</cc>
    
    <cc>ryuan.choi</cc>
    
    <cc>zoltan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1057015</commentid>
    <comment_count>0</comment_count>
    <who name="Csaba Osztrogonác">ossy</who>
    <bug_when>2014-12-19 00:35:39 -0800</bug_when>
    <thetext>at least on EFL and GTK bots, because there is no malloc measuring on Mac bots.

before:
--------
https://build.webkit.org/builders/GTK%20Linux%2064-bit%20Release%20%28Perf%29/builds/1382

Running Canvas/reuse.html (33 of 141)
RESULT Canvas: reuse: Runs= 70.7723901718 runs/s
median= 63.5780801678 runs/s, stdev= 13.4939255648 runs/s, min= 62.5708614903 runs/s, max= 97.1289885232 runs/s
RESULT Canvas: reuse: JSHeap= 267628.8 bytes
median= 269721.0 bytes, stdev= 3148.69720093 bytes, min= 261820.0 bytes, max= 269721.0 bytes
RESULT Canvas: reuse: Malloc= 1009948.4 bytes
median= 985512.0 bytes, stdev= 75773.0039181 bytes, min= 979760.0 bytes, max= 1235248.0 bytes
Finished: 25.664726 s


after:
-------
https://build.webkit.org/builders/GTK%20Linux%2064-bit%20Release%20%28Perf%29/builds/1383

Running Canvas/reuse.html (33 of 141)
RESULT Canvas: reuse: Runs= 49.7027479102 runs/s
median= 49.8827160444 runs/s, stdev= 22.7074182517 runs/s, min= 6.19658159381 runs/s, max= 124.313478825 runs/s
RESULT Canvas: reuse: JSHeap= 267201.6 bytes
median= 268569.0 bytes, stdev= 3111.07465609 bytes, min= 261788.0 bytes, max= 269689.0 bytes
RESULT Canvas: reuse: Malloc= 11552632.0 bytes
median= 9958680.0 bytes, stdev= 3720965.90803 bytes, min= 5353752.0 bytes, max= 23708440.0 bytes
Finished: 42.262450 s


Malloc= 1 009 948.4 bytes --&gt; Malloc= 11 552 632.0 bytes 
--&gt; 11x memory regression

And after this change the EFL performance bot is very flakey, WTR consumes more than 
8Gb memory for Canvas/reuse.html which causes swapping and causes OOM or timeout 
regularly. And of course swapping makes the whole performance measuring unreliable.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1057016</commentid>
    <comment_count>1</comment_count>
    <who name="Csaba Osztrogonác">ossy</who>
    <bug_when>2014-12-19 00:36:18 -0800</bug_when>
    <thetext>I have no time and plan to fix it myself, feel free to pick it up, if you are interested in it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1057052</commentid>
    <comment_count>2</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2014-12-19 10:14:04 -0800</bug_when>
    <thetext>That is very interesting. Thanks for the report Ossy. I&apos;ll take a look at this soon.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1057326</commentid>
    <comment_count>3</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2014-12-21 14:38:17 -0800</bug_when>
    <thetext>This looks similar to https://bugs.webkit.org/show_bug.cgi?id=138915. However, that bug has been fixed and it seems Canvas/reuse.html has not recovered on the GTK bots.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1057327</commentid>
    <comment_count>4</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2014-12-21 14:42:41 -0800</bug_when>
    <thetext>I am not very familiar with these memory tests. Do these results really show that we are leaking memory or simply that we are allocating a lot more than we used to?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1057329</commentid>
    <comment_count>5</comment_count>
    <who name="Csaba Osztrogonác">ossy</who>
    <bug_when>2014-12-21 14:53:09 -0800</bug_when>
    <thetext>(In reply to comment #4)
&gt; I am not very familiar with these memory tests. Do these results really show
&gt; that we are leaking memory or simply that we are allocating a lot more than
&gt; we used to?

These tests show that we allocates 10x more memory than previously, but 
nothing about leaking. But I thought that memory is leaking here, because 
WTR consumes more than 8G and then the machine started swapping. I checked 
the memory consumption in htop with EFL&apos;s WTR.

I can take a look at it in january.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1057599</commentid>
    <comment_count>6</comment_count>
    <who name="Csaba Osztrogonác">ossy</who>
    <bug_when>2014-12-23 09:17:20 -0800</bug_when>
    <thetext>note: I skipped Canvas/reuse.html on the EFL performance 
bot locally as a workaround until proper fix.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1059960</commentid>
    <comment_count>7</comment_count>
    <who name="Csaba Osztrogonác">ossy</who>
    <bug_when>2015-01-08 14:46:29 -0800</bug_when>
    <thetext>&gt; I can take a look at it in january.

I won&apos;t have time for this bug in the near future, 
feel free to pick it up. Anyone from EFL/GTK maintainers?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1059999</commentid>
    <comment_count>8</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2015-01-08 16:09:15 -0800</bug_when>
    <thetext>(In reply to comment #6)
&gt; note: I skipped Canvas/reuse.html on the EFL performance 
&gt; bot locally as a workaround until proper fix.

This is interesting... How do you did it? I didn&apos;t know that the perf tests can be skipped.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1060006</commentid>
    <comment_count>9</comment_count>
    <who name="Csaba Osztrogonác">ossy</who>
    <bug_when>2015-01-08 16:14:24 -0800</bug_when>
    <thetext>(In reply to comment #8)
&gt; This is interesting... How do you did it? I didn&apos;t know that the perf tests
&gt; can be skipped.

PerformanceTests/Skipped - but it isn&apos;t so sophisticated 
as TestExpectations for LayoutTests</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1060776</commentid>
    <comment_count>10</comment_count>
    <who name="Csaba Osztrogonác">ossy</who>
    <bug_when>2015-01-13 00:33:28 -0800</bug_when>
    <thetext>(In reply to comment #6)
&gt; note: I skipped Canvas/reuse.html on the EFL performance 
&gt; bot locally as a workaround until proper fix.

Unfortunately I have to add this ugly local hack again and again,
because the repository is wiped regularly because of some random
SVN fail. 

I don&apos;t have resource to do it regularly and I won&apos;t do it.

It would be great if the EFL maintainers could fix this serious and 1.5 
months old regression. If nobody is interested in fixing this bug, I can&apos;t
guarantee that the performance bot will provide valid results. If it starts
swapping, the results will become useless.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1060796</commentid>
    <comment_count>11</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2015-01-13 03:42:52 -0800</bug_when>
    <thetext>(In reply to comment #10)
&gt; (In reply to comment #6)
&gt; &gt; note: I skipped Canvas/reuse.html on the EFL performance 
&gt; &gt; bot locally as a workaround until proper fix.
&gt; 
&gt; Unfortunately I have to add this ugly local hack again and again,
&gt; because the repository is wiped regularly because of some random
&gt; SVN fail. 
&gt; 
&gt; I don&apos;t have resource to do it regularly and I won&apos;t do it.
&gt; 
&gt; It would be great if the EFL maintainers could fix this serious and 1.5 
&gt; months old regression. If nobody is interested in fixing this bug, I can&apos;t
&gt; guarantee that the performance bot will provide valid results. If it starts
&gt; swapping, the results will become useless.

Maybe we can implement support for port-specific skipped lists.

Something like: PerformanceTests/Skipped.efl that will add on top of the general list of PerformanceTests/Skipped list for the EFL port.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1060797</commentid>
    <comment_count>12</comment_count>
    <who name="Csaba Osztrogonác">ossy</who>
    <bug_when>2015-01-13 03:46:56 -0800</bug_when>
    <thetext>(In reply to comment #11)
&gt; Something like: PerformanceTests/Skipped.efl that will add on top of the
&gt; general list of PerformanceTests/Skipped list for the EFL port.

I&apos;d prefer fixing bugs instead of implementing a sophisticated mechanism 
to skip tests to hide real/serious/annoying bugs/regressions.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1065522</commentid>
    <comment_count>13</comment_count>
    <who name="Csaba Osztrogonác">ossy</who>
    <bug_when>2015-01-30 01:40:34 -0800</bug_when>
    <thetext>Any plan to fix this 2 months old serious regression? Or any plan to develop
a sophisticated mechanism to be able to skip the failing test on EFL only?

I had to skip it manually on the bot again because an SNV error caused 
a new checkout. :-/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1065579</commentid>
    <comment_count>14</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2015-01-30 09:54:15 -0800</bug_when>
    <thetext>(In reply to comment #13)
&gt; Any plan to fix this 2 months old serious regression? Or any plan to develop
&gt; a sophisticated mechanism to be able to skip the failing test on EFL only?
&gt; 
&gt; I had to skip it manually on the bot again because an SNV error caused 
&gt; a new checkout. :-/

I did take a look but I couldn&apos;t find what&apos;s wrong. Also, I cannot reproduce the issue on Mac so it makes it inconvenient to debug. On WebKit trunk, we are now keeping weak pointers to the canvas elements causing DOM timer throttling:
Vector&lt;WeakPtr&lt;Element&gt;&gt; m_elementsCausingThrottling;

My initial patch did cause leaking but the issue went away when I switched to WeakPtr later on. It seems EFK / GTK still experience leaking (or at least huge memory usage) but I have no idea why.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066072</commentid>
    <comment_count>15</comment_count>
    <who name="Csaba Osztrogonác">ossy</who>
    <bug_when>2015-02-02 04:20:00 -0800</bug_when>
    <thetext>Hi Chris,

thanks for checking this bug, but it would be better if EFL/GTK maintainers
could debug and fix this serious regression. I checked, the bug is still valid
at least on EFL, WebProcess consumes 6+ Gb memory on Canvas/reuse.html. It is
a serious memory leak.

Additionally I prepared a patch to skip this test on EFL - bug141152 .</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066075</commentid>
    <comment_count>16</comment_count>
    <who name="Csaba Osztrogonác">ossy</who>
    <bug_when>2015-02-02 04:48:48 -0800</bug_when>
    <thetext>I checked the bug is still valid on GTK too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066117</commentid>
    <comment_count>17</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2015-02-02 09:09:46 -0800</bug_when>
    <thetext>I debugged this for a while but couldn&apos;t find the problem :-(</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066242</commentid>
    <comment_count>18</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2015-02-02 14:47:52 -0800</bug_when>
    <thetext>I have patched run-perf-tests to allow a wrapper command: bug 141172.


This is the output of:

$ Tools/Scripts/run-perf-tests --no-show-results --platform gtk --release -2 --wrapper=&apos;valgrind --trace-children=yes --smc-check=all&apos; Canvas/reuse.html

http://sprunge.us/PhAb</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066340</commentid>
    <comment_count>19</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2015-02-02 20:20:55 -0800</bug_when>
    <thetext>I don&apos;t know what is the problem, but I think I know where is it.
This is the trace I got:

85	    void setScriptMadeNonUserObservableChangesToElement(Element&amp; element)
86	    {
87	        m_scriptMadeNonUserObservableChanges = true;
88	        m_elementsChangedOutsideViewport.add(&amp;element); &lt;------- http://trac.webkit.org/browser/trunk/Source/WebCore/page/DOMTimer.cpp?rev=179534#L88
89	    }
90	


313	void DOMTimer::scriptDidCauseElementRepaint(Element&amp; element, bool mayRepaintNonDescendants)
314	{
315	    if (!DOMTimerFireState::current)
316	        return;
317	
318	    if (mayRepaintNonDescendants || element.mayCauseRepaintInsideViewport())
319	        DOMTimerFireState::current-&gt;setScriptMadeUserObservableChanges();
320	    else
321	        DOMTimerFireState::current-&gt;setScriptMadeNonUserObservableChangesToElement(element);  &lt;------- http://trac.webkit.org/browser/trunk/Source/WebCore/page/DOMTimer.cpp?rev=179534#L321
322	}


280	void HTMLCanvasElement::notifyObserversCanvasChanged(const FloatRect&amp; rect)
281	{
282	    // Choke point for canvas drawing; notify DOMTimer of the event.
283	    DOMTimer::scriptDidCauseElementRepaint(*this);                        &lt;------- http://trac.webkit.org/browser/trunk/Source/WebCore/html/HTMLCanvasElement.cpp?rev=179534#L283
284	
285	    for (auto it = m_observers.begin(), end = m_observers.end(); it != end; ++it)
286	        (*it)-&gt;canvasChanged(*this, rect);
287	}


Seems that either commenting line 283 of Source/WebCore/html/HTMLCanvasElement.cpp or line 88 of Source/WebCore/page/DOMTimer.cpp fixes the problem.

When running the perf test Canvas/reuse.html, the above trace gets executed around 24K times.

I wonder if the memory issues have to be with adding the element so many times to m_elementsChangedOutsideViewport ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066348</commentid>
    <comment_count>20</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2015-02-02 20:38:00 -0800</bug_when>
    <thetext>(In reply to comment #19)
&gt; I don&apos;t know what is the problem, but I think I know where is it.
&gt; This is the trace I got:
&gt; 
&gt; 85	    void setScriptMadeNonUserObservableChangesToElement(Element&amp; element)
&gt; 86	    {
&gt; 87	        m_scriptMadeNonUserObservableChanges = true;
&gt; 88	        m_elementsChangedOutsideViewport.add(&amp;element); &lt;-------
&gt; http://trac.webkit.org/browser/trunk/Source/WebCore/page/DOMTimer.
&gt; cpp?rev=179534#L88
&gt; 89	    }
&gt; 90	
&gt; 
&gt; 
&gt; 313	void DOMTimer::scriptDidCauseElementRepaint(Element&amp; element, bool
&gt; mayRepaintNonDescendants)
&gt; 314	{
&gt; 315	    if (!DOMTimerFireState::current)
&gt; 316	        return;
&gt; 317	
&gt; 318	    if (mayRepaintNonDescendants ||
&gt; element.mayCauseRepaintInsideViewport())
&gt; 319	        DOMTimerFireState::current-&gt;setScriptMadeUserObservableChanges();
&gt; 320	    else
&gt; 321	       
&gt; DOMTimerFireState::current-
&gt; &gt;setScriptMadeNonUserObservableChangesToElement(element);  &lt;-------
&gt; http://trac.webkit.org/browser/trunk/Source/WebCore/page/DOMTimer.
&gt; cpp?rev=179534#L321
&gt; 322	}
&gt; 
&gt; 
&gt; 280	void HTMLCanvasElement::notifyObserversCanvasChanged(const FloatRect&amp;
&gt; rect)
&gt; 281	{
&gt; 282	    // Choke point for canvas drawing; notify DOMTimer of the event.
&gt; 283	    DOMTimer::scriptDidCauseElementRepaint(*this);                      
&gt; &lt;-------
&gt; http://trac.webkit.org/browser/trunk/Source/WebCore/html/HTMLCanvasElement.
&gt; cpp?rev=179534#L283
&gt; 284	
&gt; 285	    for (auto it = m_observers.begin(), end = m_observers.end(); it !=
&gt; end; ++it)
&gt; 286	        (*it)-&gt;canvasChanged(*this, rect);
&gt; 287	}
&gt; 
&gt; 
&gt; Seems that either commenting line 283 of
&gt; Source/WebCore/html/HTMLCanvasElement.cpp or line 88 of
&gt; Source/WebCore/page/DOMTimer.cpp fixes the problem.
&gt; 
&gt; When running the perf test Canvas/reuse.html, the above trace gets executed
&gt; around 24K times.
&gt; 
&gt; I wonder if the memory issues have to be with adding the element so many
&gt; times to m_elementsChangedOutsideViewport ?

m_elementsChangedOutsideViewport is a HashSet so adding the same element many times should not blow up memory. However, m_elementsChangedOutsideViewport is ref-ing the elements. The reason this is supposed to be OK is because the HashSet gets cleared when the DOMTimerFireState object gets destroyed (which happens after the timer&apos;s callback is done executing). If m_elementsChangedOutsideViewport would not get cleared, for one reason or another, then we could keep a ref to the canvas elements and leak. It would be interesting to check if m_elementsChangedOutsideViewport gets cleared and when.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066397</commentid>
    <comment_count>21</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2015-02-03 03:10:48 -0800</bug_when>
    <thetext>The problem is that it&apos;s not the same element, but a different one every time because the test is creating a lot of canvas elements. Before r176609, nobody was holding a ref of the canvases so they were released before the next one is created. And the new one was created using the same memory of the recently release one. Now the DOMTimerFireState is holding a reference of all canvases created, preventing the memory allocator to reuse the memory. DOMTimerFireState is indeed correctly destroyed, but when destroyed it contains a lot of canvases in m_elementsChangedOutsideViewport that are all correctly released as well.
I wonder why this doesn&apos;t happen in mac, though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066429</commentid>
    <comment_count>22</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2015-02-03 07:41:33 -0800</bug_when>
    <thetext>(In reply to comment #21)
&gt; I wonder why this doesn&apos;t happen in mac, though.

We don&apos;t know if it happens on Mac or not.

Unfortunately the Mac perf bots don&apos;t report malloc stats. I don&apos;t know why.

If you check the stdout from the bots, mac per bots always report &quot;Malloc= 0.0 bytes&quot; for every perf test:

https://build.webkit.org/builders/Apple%20Mavericks%20Release%20%28Perf%29/builds/3834/steps/perf-test/logs/stdio
https://build.webkit.org/builders/Apple%20Yosemite%20Release%20%28Perf%29/builds/911/steps/perf-test/logs/stdio

Compare that with GTK or EFL:

https://build.webkit.org/builders/GTK%20Linux%2064-bit%20Release%20%28Perf%29/builds/1861/steps/perf-test/logs/stdio
https://build.webkit.org/builders/EFL%20Linux%2064-bit%20Release%20WK2%20%28Perf%29/builds/4669/steps/perf-test/logs/stdio

Also the charts at perf.webkit.org don&apos;t show any data for the malloc graphs on the mac bots.

https://perf.webkit.org/#mode=charts&amp;chartList=%5B%5B%22efl%22%2C%22Canvas%2Freuse%3AMalloc%22%5D%2C%5B%22gtk%22%2C%22Canvas%2Freuse%3AMalloc%22%5D%2C%5B%22mac-mavericks%22%2C%22Canvas%2Freuse%3AMalloc%22%5D%2C%5B%22mac-yosemite%22%2C%22Canvas%2Freuse%3AMalloc%22%5D%5D

https://perf.webkit.org/#mode=charts&amp;chartList=%5B%5B%22efl%22%2C%22Canvas%2Fterrain%3AMalloc%22%5D%2C%5B%22gtk%22%2C%22Canvas%2Fterrain%3AMalloc%22%5D%2C%5B%22mac-mavericks%22%2C%22Canvas%2Fterrain%3AMalloc%22%5D%2C%5B%22mac-yosemite%22%2C%22Canvas%2Fterrain%3AMalloc%22%5D%5D

Maybe this memory leak in Canvas/reuse.html is also happening on Mac and nobody noticed so far ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066431</commentid>
    <comment_count>23</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2015-02-03 07:56:27 -0800</bug_when>
    <thetext>(In reply to comment #22)
&gt; (In reply to comment #21)
&gt; &gt; I wonder why this doesn&apos;t happen in mac, though.
&gt; 
&gt; We don&apos;t know if it happens on Mac or not.
&gt; 
&gt; Unfortunately the Mac perf bots don&apos;t report malloc stats. I don&apos;t know why.
&gt; 

On Linux the results also don&apos;t inspire much confidence.

I get:

$ Tools/Scripts/run-perf-tests --platform gtk --release -2 --no-show-results Canvas/reuse.html 
Running 1 tests
Running Canvas/reuse.html (1 of 1)
RESULT Canvas: reuse: Runs= 65.1449948365 runs/s
median= 62.5518991775 runs/s, stdev= 23.3810442109 runs/s, min= 40.9716005343 runs/s, max= 130.779642838 runs/s
RESULT Canvas: reuse: JSHeap= 259981.2 bytes
median= 262303.0 bytes, stdev= 3179.22177833 bytes, min= 254434.0 bytes, max= 262399.0 bytes
RESULT Canvas: reuse: Malloc= 14886120.8 bytes
median= 14636376.0 bytes, stdev= 4064045.72291 bytes, min= 10082480.0 bytes, max= 23832928.0 bytes
Finished: 32.045871 s


And looking at htop, WebKitWebProcess sucked nearly 8GB of RAM while running.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066461</commentid>
    <comment_count>24</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2015-02-03 09:44:53 -0800</bug_when>
    <thetext>(In reply to comment #22)
&gt; Maybe this memory leak in Canvas/reuse.html is also happening on Mac and
&gt; nobody noticed so far ?

Note that according to my analysis, this is not a memory leak, all memory allocated is correctly freed, the difference is that since r176609 the test requires a lot of more memory because a lot of canvases are created and they are released all together.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066463</commentid>
    <comment_count>25</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2015-02-03 09:50:35 -0800</bug_when>
    <thetext>(In reply to comment #24)
&gt; (In reply to comment #22)
&gt; &gt; Maybe this memory leak in Canvas/reuse.html is also happening on Mac and
&gt; &gt; nobody noticed so far ?
&gt; 
&gt; Note that according to my analysis, this is not a memory leak, all memory
&gt; allocated is correctly freed, the difference is that since r176609 the test
&gt; requires a lot of more memory because a lot of canvases are created and they
&gt; are released all together.

Right, I&apos;m re-titling the bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066469</commentid>
    <comment_count>26</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2015-02-03 10:05:19 -0800</bug_when>
    <thetext>Looking at the code of this test, it appears it creates 62 canvas per timer firing. After creating and drawing to those 62 canvases, it calls window.GCController.collect() at the end of the Timer callback. Unfortunately, at this point, DOMTimerFireState is still holding a ref to those canvases so they don&apos;t get garbage collected. Between DOM timer firing, DOMTimerFireState is destroyed and the canvases are unref&apos;d. They could then we garbage-collected at any point but this doesn&apos;t seem to happen on those bots.

I am still thinking about how best address this problem. We could potentially use WeakPointers in DOMTimerFireState like I already do in DOMTimer.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066473</commentid>
    <comment_count>27</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2015-02-03 10:15:29 -0800</bug_when>
    <thetext>Here the test creates a lot more than 62 canvases, see:

DBG: [0x7fff318ed760] DOMTimerFireState
DBG: [0x7fff318ed760] ~DOMTimerFireState: elementsChangedOutsideViewport: 15562
DBG: [0x7fff318ed760] DOMTimerFireState
DBG: [0x7fff318ed760] ~DOMTimerFireState: elementsChangedOutsideViewport: 2480
DBG: [0x7fff318ed760] DOMTimerFireState
DBG: [0x7fff318ed760] ~DOMTimerFireState: elementsChangedOutsideViewport: 2480
DBG: [0x7fff318ed760] DOMTimerFireState
DBG: [0x7fff318ed760] ~DOMTimerFireState: elementsChangedOutsideViewport: 2480
DBG: [0x7fff318ed760] DOMTimerFireState
DBG: [0x7fff318ed760] ~DOMTimerFireState: elementsChangedOutsideViewport: 2480
DBG: [0x7fff318ed760] DOMTimerFireState
DBG: [0x7fff318ed760] ~DOMTimerFireState: elementsChangedOutsideViewport: 2480
Content-Type: text/plain

:Runs -&gt; [48.22815776870716, 48.52301992733968, 42.84591110766597, 18.28278068295747, 49.92928764631812] runs/s

:JSHeap -&gt; [256914, 262271, 262335, 262335, 262335] bytes

:Malloc -&gt; [10129328, 10084928, 10070336, 10070264, 10070224] bytes

#EOF
#EOF
#EOF</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066477</commentid>
    <comment_count>28</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2015-02-03 10:18:55 -0800</bug_when>
    <thetext>(In reply to comment #27)
&gt; Here the test creates a lot more than 62 canvases, see:
&gt; 
&gt; DBG: [0x7fff318ed760] DOMTimerFireState
&gt; DBG: [0x7fff318ed760] ~DOMTimerFireState: elementsChangedOutsideViewport:
&gt; 15562
&gt; DBG: [0x7fff318ed760] DOMTimerFireState
&gt; DBG: [0x7fff318ed760] ~DOMTimerFireState: elementsChangedOutsideViewport:
&gt; 2480
&gt; DBG: [0x7fff318ed760] DOMTimerFireState
&gt; DBG: [0x7fff318ed760] ~DOMTimerFireState: elementsChangedOutsideViewport:
&gt; 2480
&gt; DBG: [0x7fff318ed760] DOMTimerFireState
&gt; DBG: [0x7fff318ed760] ~DOMTimerFireState: elementsChangedOutsideViewport:
&gt; 2480
&gt; DBG: [0x7fff318ed760] DOMTimerFireState
&gt; DBG: [0x7fff318ed760] ~DOMTimerFireState: elementsChangedOutsideViewport:
&gt; 2480
&gt; DBG: [0x7fff318ed760] DOMTimerFireState
&gt; DBG: [0x7fff318ed760] ~DOMTimerFireState: elementsChangedOutsideViewport:
&gt; 2480
&gt; Content-Type: text/plain
&gt; 
&gt; :Runs -&gt; [48.22815776870716, 48.52301992733968, 42.84591110766597,
&gt; 18.28278068295747, 49.92928764631812] runs/s
&gt; 
&gt; :JSHeap -&gt; [256914, 262271, 262335, 262335, 262335] bytes
&gt; 
&gt; :Malloc -&gt; [10129328, 10084928, 10070336, 10070264, 10070224] bytes
&gt; 
&gt; #EOF
&gt; #EOF
&gt; #EOF

I see, well it is not obvious to me how many times testCreation() is called for each DOM timer firing because the test is using PerfTestRunner.measureRunsPerSecond(). In any case, I understand the issue now. I believe the right fix is to use WeakPointers like we already do in DOMTimer. I am working on this now and will propose a patch soon. Thanks a lot for investigating this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066520</commentid>
    <comment_count>29</comment_count>
      <attachid>245952</attachid>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2015-02-03 12:07:26 -0800</bug_when>
    <thetext>Created attachment 245952
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066521</commentid>
    <comment_count>30</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2015-02-03 12:08:35 -0800</bug_when>
    <thetext>Before I set the patch up for review, could someone from the GTK/EFL port confirm that it indeed fixes the problem you&apos;re seeing? Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066581</commentid>
    <comment_count>31</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2015-02-03 15:09:26 -0800</bug_when>
    <thetext>(In reply to comment #30)
&gt; Before I set the patch up for review, could someone from the GTK/EFL port
&gt; confirm that it indeed fixes the problem you&apos;re seeing? Thanks!

Tested it. At least on GTK, It fixes completely the problem :)

Some numbers: When running Canvas/reuse.html, peak memory is.

Before this patch -&gt; mapped: 15695984K  writeable/private: 13557976K  shared: 32K
After  this patch -&gt; mapped:  2423560K  writeable/private:   286872K  shared: 32K


Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066586</commentid>
    <comment_count>32</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2015-02-03 15:13:23 -0800</bug_when>
    <thetext>(In reply to comment #31)
&gt; (In reply to comment #30)
&gt; &gt; Before I set the patch up for review, could someone from the GTK/EFL port
&gt; &gt; confirm that it indeed fixes the problem you&apos;re seeing? Thanks!
&gt; 
&gt; Tested it. At least on GTK, It fixes completely the problem :)
&gt; 
&gt; Some numbers: When running Canvas/reuse.html, peak memory is.
&gt; 
&gt; Before this patch -&gt; mapped: 15695984K  writeable/private: 13557976K 
&gt; shared: 32K
&gt; After  this patch -&gt; mapped:  2423560K  writeable/private:   286872K 
&gt; shared: 32K
&gt; 
&gt; 
&gt; Thanks!

Excellent, thanks for confirming.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066598</commentid>
    <comment_count>33</comment_count>
      <attachid>245952</attachid>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2015-02-03 15:21:07 -0800</bug_when>
    <thetext>Comment on attachment 245952
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=245952&amp;action=review

&gt; Source/WebCore/page/DOMTimer.cpp:119
&gt; +    HashMap&lt;Element*, WeakPtr&lt;Element&gt;&gt; m_elementsChangedOutsideViewport;

FYI, the reason I did not use a WeakGCMap is because it seems to require the values to be of Weak&lt;&gt; type. In this case, my values have WeakPtr&lt;Element&gt; type.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066628</commentid>
    <comment_count>34</comment_count>
      <attachid>245952</attachid>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2015-02-03 16:06:55 -0800</bug_when>
    <thetext>Comment on attachment 245952
Patch

r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066643</commentid>
    <comment_count>35</comment_count>
      <attachid>245952</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2015-02-03 16:51:14 -0800</bug_when>
    <thetext>Comment on attachment 245952
Patch

Clearing flags on attachment: 245952

Committed r179581: &lt;http://trac.webkit.org/changeset/179581&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066644</commentid>
    <comment_count>36</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2015-02-03 16:51:19 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066767</commentid>
    <comment_count>37</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2015-02-04 00:13:10 -0800</bug_when>
    <thetext>Thank you Chris!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066790</commentid>
    <comment_count>38</comment_count>
    <who name="Csaba Osztrogonác">ossy</who>
    <bug_when>2015-02-04 07:02:34 -0800</bug_when>
    <thetext>Thanks for the fix, it helped for EFL too, I already unskipped the test on the bot.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1066799</commentid>
    <comment_count>39</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2015-02-04 07:37:51 -0800</bug_when>
    <thetext>(In reply to comment #22)
&gt; (In reply to comment #21)
&gt; &gt; I wonder why this doesn&apos;t happen in mac, though.
&gt; 
&gt; We don&apos;t know if it happens on Mac or not.
&gt; 
&gt; Unfortunately the Mac perf bots don&apos;t report malloc stats. I don&apos;t know why.
&gt; 
&gt; If you check the stdout from the bots, mac per bots always report &quot;Malloc=
&gt; 0.0 bytes&quot; for every perf test:
&gt; 

Seems that the cause is that bmalloc don&apos;t implements reporting of stats. I reported that on bug 141247</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>245952</attachid>
            <date>2015-02-03 12:07:26 -0800</date>
            <delta_ts>2015-02-03 16:51:14 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-139812-20150203120726.patch</filename>
            <type>text/plain</type>
            <size>3139</size>
            <attacher name="Chris Dumez">cdumez</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTc5NTUwCmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggZTNkYzUwNjNmMjI1OWUw
YjNlOWEwMzNlNmFiMDExZjgzN2QzODBiMS4uZGNjODg5OTU4MmY1MTc4Y2RmN2UxZWQ0MGZhMGJh
YzkyYTQwMjgyNiAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDIyIEBACisyMDE1LTAyLTAzICBDaHJp
cyBEdW1leiAgPGNkdW1lekBhcHBsZS5jb20+CisKKyAgICAgICAgUkVHUkVTU0lPTigxNzY2MDkp
OiBWZXJ5IGhpZ2ggbWVtb3J5IHVzYWdlIGluIENhbnZhcy9yZXVzZS5odG1sIHBlcmZvcm1hbmNl
IHRlc3QKKyAgICAgICAgaHR0cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lkPTEz
OTgxMgorCisgICAgICAgIFJldmlld2VkIGJ5IE5PQk9EWSAoT09QUyE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aWRlVmlld3BvcnQ7CisgICAgSGFzaE1hcDxFbGVtZW50KiwgV2Vha1B0cjxFbGVtZW50Pj4gbV9l
bGVtZW50c0NoYW5nZWRPdXRzaWRlVmlld3BvcnQ7CiAgICAgYm9vbCBtX2NvbnRleHRJc0RvY3Vt
ZW50OwogICAgIGJvb2wgbV9zY3JpcHRNYWRlTm9uVXNlck9ic2VydmFibGVDaGFuZ2VzIHsgZmFs
c2UgfTsKICAgICBib29sIG1fc2NyaXB0TWFkZVVzZXJPYnNlcnZhYmxlQ2hhbmdlcyB7IGZhbHNl
IH07Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>