<?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>86609</bug_id>
          
          <creation_ts>2012-05-16 04:59:03 -0700</creation_ts>
          <short_desc>[EFL] Memory leak in RenderThemeEfl</short_desc>
          <delta_ts>2012-05-16 09:00:14 -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>WebKit EFL</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>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Sudarsana Nagineni (babu)">naginenis</reporter>
          <assigned_to name="Sudarsana Nagineni (babu)">naginenis</assigned_to>
          <cc>antognolli+webkit</cc>
    
    <cc>gustavo</cc>
    
    <cc>gyuyoung.kim</cc>
    
    <cc>gyuyoung.kim</cc>
    
    <cc>lucas.de.marchi</cc>
    
    <cc>mrobinson</cc>
    
    <cc>pnormand</cc>
    
    <cc>rakuco</cc>
    
    <cc>webkit.review.bot</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>625283</commentid>
    <comment_count>0</comment_count>
    <who name="Sudarsana Nagineni (babu)">naginenis</who>
    <bug_when>2012-05-16 04:59:03 -0700</bug_when>
    <thetext>Valgrind reports a memory leak in RenderThemeEfl. I guess the cairo surface needs to be freed when the RenderTheme is destroyed.

==11717==
==11717== 368 bytes in 1 blocks are definitely lost in loss record 9,399 of 11,096
==11717==    at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==11717==    by 0x5073D6F: _cairo_image_surface_create_for_pixman_image (cairo-image-surface.c:158)
==11717==    by 0x5076698: _cairo_image_surface_create_with_pixman_format (cairo-image-surface.c:335)
==11717==    by 0x9D3A0E5: WebCore::RenderThemeEfl::themePartCacheEntrySurfaceCreate(WebCore::RenderThemeEfl::ThemePartCacheEntry*) (RenderThemeEfl.cpp:135)
==11717==    by 0x9D3A430: WebCore::RenderThemeEfl::cacheThemePartNew(WebCore::FormType, WebCore::IntSize const&amp;) (RenderThemeEfl.cpp:190)
==11717==    by 0x9D3A766: WebCore::RenderThemeEfl::cacheThemePartGet(WebCore::FormType, WebCore::IntSize const&amp;) (RenderThemeEfl.cpp:259)
==11717==    by 0x9D3AA8E: WebCore::RenderThemeEfl::paintThemePart(WebCore::RenderObject*, WebCore::FormType, WebCore::PaintInfo const&amp;, WebCore::IntRect const&amp;) (RenderThemeEfl.cpp:319)
==11717==    by 0x9D3D448: WebCore::RenderThemeEfl::paintMenuList(WebCore::RenderObject*, WebCore::PaintInfo const&amp;, WebCore::IntRect const&amp;) (RenderThemeEfl.cpp:869)
==11717==    by 0x9612898: WebCore::RenderTheme::paint(WebCore::RenderObject*, WebCore::PaintInfo const&amp;, WebCore::IntRect const&amp;) (RenderTheme.cpp:292)
==11717==    by 0x950FEAF: WebCore::RenderBox::paintBoxDecorations(WebCore::PaintInfo&amp;, WebCore::FractionalLayoutPoint const&amp;) (RenderBox.cpp:960)
==11717==    by 0x94B52E1: WebCore::RenderBlock::paintObject(WebCore::PaintInfo&amp;, WebCore::FractionalLayoutPoint const&amp;) (RenderBlock.cpp:2758)
==11717==    by 0x94B3217: WebCore::RenderBlock::paint(WebCore::PaintInfo&amp;, WebCore::FractionalLayoutPoint const&amp;) (RenderBlock.cpp:2528)
==11717==    by 0x948A552: WebCore::InlineBox::paint(WebCore::PaintInfo&amp;, WebCore::FractionalLayoutPoint const&amp;, WebCore::FractionalLayoutUnit, WebCore::FractionalLayoutUnit) (InlineBox.cpp:232)
==11717==    by 0x9490622: WebCore::InlineFlowBox::paint(WebCore::PaintInfo&amp;, WebCore::FractionalLayoutPoint const&amp;, WebCore::FractionalLayoutUnit, WebCore::FractionalLayoutUnit) (InlineFlowBox.cpp:1078)
==11717==    by 0x962E48E: WebCore::RootInlineBox::paint(WebCore::PaintInfo&amp;, WebCore::FractionalLayoutPoint const&amp;, WebCore::FractionalLayoutUnit, WebCore::FractionalLayoutUnit) (RootInlineBox.cpp:206)
==11717==    by 0x959F959: WebCore::RenderLineBoxList::paint(WebCore::RenderBoxModelObject*, WebCore::PaintInfo&amp;, WebCore::FractionalLayoutPoint const&amp;) const (RenderLineBoxList.cpp:262)
==11717==    by 0x94B49C0: WebCore::RenderBlock::paintContents(WebCore::PaintInfo&amp;, WebCore::FractionalLayoutPoint const&amp;) (RenderBlock.cpp:2672)
==11717==    by 0x94B5466: WebCore::RenderBlock::paintObject(WebCore::PaintInfo&amp;, WebCore::FractionalLayoutPoint const&amp;) (RenderBlock.cpp:2782)
==11717==    by 0x94B3217: WebCore::RenderBlock::paint(WebCore::PaintInfo&amp;, WebCore::FractionalLayoutPoint const&amp;) (RenderBlock.cpp:2528)
==11717==    by 0x94B4E45: WebCore::RenderBlock::paintChildren(WebCore::PaintInfo&amp;, WebCore::FractionalLayoutPoint const&amp;) (RenderBlock.cpp:2716)
==11717==    by 0x94B49D9: WebCore::RenderBlock::paintContents(WebCore::PaintInfo&amp;, WebCore::FractionalLayoutPoint const&amp;) (RenderBlock.cpp:2674)
==11717==    by 0x94B5466: WebCore::RenderBlock::paintObject(WebCore::PaintInfo&amp;, WebCore::FractionalLayoutPoint const&amp;) (RenderBlock.cpp:2782)
==11717==    by 0x94B3217: WebCore::RenderBlock::paint(WebCore::PaintInfo&amp;, WebCore::FractionalLayoutPoint const&amp;) (RenderBlock.cpp:2528)
==11717==    by 0x94B4E45: WebCore::RenderBlock::paintChildren(WebCore::PaintInfo&amp;, WebCore::FractionalLayoutPoint const&amp;) (RenderBlock.cpp:2716)
==11717==    by 0x94B49D9: WebCore::RenderBlock::paintContents(WebCore::PaintInfo&amp;, WebCore::FractionalLayoutPoint const&amp;) (RenderBlock.cpp:2674)
==11717==    by 0x94B5466: WebCore::RenderBlock::paintObject(WebCore::PaintInfo&amp;, WebCore::FractionalLayoutPoint const&amp;) (RenderBlock.cpp:2782)
==11717==    by 0x94B3217: WebCore::RenderBlock::paint(WebCore::PaintInfo&amp;, WebCore::FractionalLayoutPoint const&amp;) (RenderBlock.cpp:2528)
==11717==    by 0x958EA3D: WebCore::RenderLayer::paintLayerContents(WebCore::RenderLayer*, WebCore::GraphicsContext*, WebCore::FractionalLayoutRect const&amp;, unsigned int, WebCore::RenderObject*, WebCore::Re
==11717==    by 0x958E34A: WebCore::RenderLayer::paintLayerContentsAndReflection(WebCore::RenderLayer*, WebCore::GraphicsContext*, WebCore::FractionalLayoutRect const&amp;, unsigned int, WebCore::RenderObject*
==11717==    by 0x958E24A: WebCore::RenderLayer::paintLayer(WebCore::RenderLayer*, WebCore::GraphicsContext*, WebCore::FractionalLayoutRect const&amp;, unsigned int, WebCore::RenderObject*, WebCore::RenderRegi
==11717==    by 0x958F069: WebCore::RenderLayer::paintList(WTF::Vector&lt;WebCore::RenderLayer*, 0ul&gt;*, WebCore::RenderLayer*, WebCore::GraphicsContext*, WebCore::FractionalLayoutRect const&amp;, unsigned int, We
==11717==    by 0x958ECAD: WebCore::RenderLayer::paintLayerContents(WebCore::RenderLayer*, WebCore::GraphicsContext*, WebCore::FractionalLayoutRect const&amp;, unsigned int, WebCore::RenderObject*, WebCore::Re
==11717==    by 0x958E34A: WebCore::RenderLayer::paintLayerContentsAndReflection(WebCore::RenderLayer*, WebCore::GraphicsContext*, WebCore::FractionalLayoutRect const&amp;, unsigned int, WebCore::RenderObject*
==11717==    by 0x958E24A: WebCore::RenderLayer::paintLayer(WebCore::RenderLayer*, WebCore::GraphicsContext*, WebCore::FractionalLayoutRect const&amp;, unsigned int, WebCore::RenderObject*, WebCore::RenderRegi
==11717==    by 0x958F069: WebCore::RenderLayer::paintList(WTF::Vector&lt;WebCore::RenderLayer*, 0ul&gt;*, WebCore::RenderLayer*, WebCore::GraphicsContext*, WebCore::FractionalLayoutRect const&amp;, unsigned int, We
==11717==    by 0x958ECAD: WebCore::RenderLayer::paintLayerContents(WebCore::RenderLayer*, WebCore::GraphicsContext*, WebCore::FractionalLayoutRect const&amp;, unsigned int, WebCore::RenderObject*, WebCore::Re
==11717==    by 0x958E34A: WebCore::RenderLayer::paintLayerContentsAndReflection(WebCore::RenderLayer*, WebCore::GraphicsContext*, WebCore::FractionalLayoutRect const&amp;, unsigned int, WebCore::RenderObject*
==11717==    by 0x958E24A: WebCore::RenderLayer::paintLayer(WebCore::RenderLayer*, WebCore::GraphicsContext*, WebCore::FractionalLayoutRect const&amp;, unsigned int, WebCore::RenderObject*, WebCore::RenderRegi
==11717==    by 0x958D6E4: WebCore::RenderLayer::paint(WebCore::GraphicsContext*, WebCore::FractionalLayoutRect const&amp;, unsigned int, WebCore::RenderObject*, WebCore::RenderRegion*, unsigned int) (RenderLa
==11717==    by 0x932E134: WebCore::FrameView::paintContents(WebCore::GraphicsContext*, WebCore::IntRect const&amp;) (FrameView.cpp:3093)
==11717==    by 0x4FDA34B: ewk_view_paint_context_paint_contents (ewk_view.cpp:2765)
==11717==    by 0x4FE7967: _ewk_view_single_smart_repaints_process(_Ewk_View_Smart_Data*) (ewk_view_single.cpp:314)
==11717==    by 0x4FC2F81: _ewk_view_smart_calculate(_Evas_Object*) (ewk_view.cpp:982)
==11717==    by 0x4E79D9B: evas_call_smarts_calculate (evas_object_smart.c:688)
==11717==    by 0x4EA0EC1: evas_render_updates_internal (evas_render.c:1359)
==11717==    by 0x41850D4: _ecore_evas_x_render (ecore_evas_x.c:281)
==11717==    by 0x41823C0: _ecore_evas_idle_enter (ecore_evas.c:59)
==11717==    by 0x41459B5: _ecore_idle_enterer_call (ecore_private.h:263)
==11717==    by 0x41470CA: _ecore_main_loop_iterate_internal (ecore_main.c:1789)
==11717==    by 0x4147726: ecore_main_loop_begin (ecore_main.c:906)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>625300</commentid>
    <comment_count>1</comment_count>
      <attachid>142226</attachid>
    <who name="Sudarsana Nagineni (babu)">naginenis</who>
    <bug_when>2012-05-16 05:29:03 -0700</bug_when>
    <thetext>Created attachment 142226
Fix memory leak

Free the surface with cairo_surface_destroy.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>625323</commentid>
    <comment_count>2</comment_count>
      <attachid>142226</attachid>
    <who name="Gyuyoung Kim">gyuyoung.kim</who>
    <bug_when>2012-05-16 05:45:54 -0700</bug_when>
    <thetext>Comment on attachment 142226
Fix memory leak

Although I&apos;m not expert this area, according to cairo API document, cairo_surface_destroy() decreases reference count(). Then, if reference count is zero, it frees resource by calling cairo_surface_finish(). In other hands, cairo_surface_finish() drops resource to external resource directly. Could you let me know why cairo_surface_destroy() can fix memory leak ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>625351</commentid>
    <comment_count>3</comment_count>
    <who name="Sudarsana Nagineni (babu)">naginenis</who>
    <bug_when>2012-05-16 06:38:33 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; (From update of attachment 142226 [details])
&gt; Although I&apos;m not expert this area, according to cairo API document, cairo_surface_destroy() decreases reference count(). Then, if reference count is zero, it frees resource by calling cairo_surface_finish(). In other hands, cairo_surface_finish() drops resource to external resource directly. Could you let me know why cairo_surface_destroy() can fix memory leak ?

cairo_surface_finish() doesn&apos;t free the surface. cairo_surface_destroy is the right function to destroy the surface when the RenderTheme is destroyed. As you already noticed that surface_destroy also calls the surface_finish when the reference count for a surface reaches zero, so we don&apos;t really need to call the surface_finish explicitly here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>625394</commentid>
    <comment_count>4</comment_count>
    <who name="Gyuyoung Kim">gyuyoung.kim</who>
    <bug_when>2012-05-16 07:20:39 -0700</bug_when>
    <thetext>rs+ on my side informally. However, I think rafael can review this patch as well. CC&apos;ing rafael.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>625443</commentid>
    <comment_count>5</comment_count>
    <who name="Rafael Antognolli">antognolli+webkit</who>
    <bug_when>2012-05-16 08:06:51 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; rs+ on my side informally. However, I think rafael can review this patch as well. CC&apos;ing rafael.

It also looks good to me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>625509</commentid>
    <comment_count>6</comment_count>
      <attachid>142226</attachid>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2012-05-16 09:00:08 -0700</bug_when>
    <thetext>Comment on attachment 142226
Fix memory leak

Clearing flags on attachment: 142226

Committed r117297: &lt;http://trac.webkit.org/changeset/117297&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>625510</commentid>
    <comment_count>7</comment_count>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2012-05-16 09:00:14 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>142226</attachid>
            <date>2012-05-16 05:29:03 -0700</date>
            <delta_ts>2012-05-16 09:00:08 -0700</delta_ts>
            <desc>Fix memory leak</desc>
            <filename>86609.patch</filename>
            <type>text/plain</type>
            <size>1298</size>
            <attacher name="Sudarsana Nagineni (babu)">naginenis</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZyBiL1NvdXJjZS9XZWJDb3JlL0No
YW5nZUxvZwppbmRleCA2MTE4MDZhLi5hZmM3MzU4IDEwMDY0NAotLS0gYS9Tb3VyY2UvV2ViQ29y
ZS9DaGFuZ2VMb2cKKysrIGIvU291cmNl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