[0.64.1] Memory leak in rendering animation.

Hi.

I’m using 0.64.1 Synfig (packaged by Debian Testing). I was rendering an animation when I notice that the use of memory increased a lot. I put an eye on and see that the used memory going on without brake. So, I need to restart Synfig every time the use of memory get danger numbers. It is not funny. :slight_smile:

I was rendering 1080x70 30fps CairoPNG.

I was looking at bug tracker but I can find nothing about memory leaks… so, could anyone confirme that?

Do you have same issue using normal PNG export (Software renderer)?
Do you use images on your animation?
-G

There’s definitely a leak in CairoPNG target:

==2743== 97,088,476 (423,900 direct, 96,664,576 indirect) bytes in 1,413 blocks are definitely lost in loss record 11,295 of 11,296 ==2743== at 0x4023F50: malloc (vg_replace_malloc.c:236) ==2743== by 0x516AA88: _cairo_image_surface_create_for_pixman_image (cairo-image-surface.c:176) ==2743== by 0x516AB77: _cairo_image_surface_create_with_pixman_format (cairo-image-surface.c:345) ==2743== by 0x516AE82: cairo_image_surface_create (cairo-image-surface.c:387) ==2743== by 0x6DED06B: cairo_png_trgt::obtain_surface(_cairo_surface*&) (in /tmp/synfigstudio-0.64.1-20131104.8.i386/lib/synfig/modules/libmod_png.so) ==2743== by 0x83C122A: AsyncTarget_Cairo::obtain_surface(_cairo_surface*&) (in /tmp/synfigstudio-0.64.1-20131104.8.i386/bin/synfigstudio) ==2743== by 0x4294CA3: synfig::Target_Cairo::render(synfig::ProgressCallback*) (in /tmp/synfigstudio-0.64.1-20131104.8.i386/lib/libsynfig.so.0.0.0) ==2743== by 0x83BE940: studio::AsyncRenderer::render_target() (in /tmp/synfigstudio-0.64.1-20131104.8.i386/bin/synfigstudio) ==2743== by 0x4F0DB07: call_thread_entry_slot (slot.h:440) ==2743== by 0x53C9A8E: ??? (in /lib/libglib-2.0.so.0.2800.6) ==2743== by 0x4679954: start_thread (pthread_create.c:300) ==2743== by 0x563A1DD: clone (clone.S:130) ==2743== ==2743== 650,592,000 bytes in 1,255 blocks are possibly lost in loss record 11,296 of 11,296 ==2743== at 0x402328F: calloc (vg_replace_malloc.c:467) ==2743== by 0x5B41559: ??? (in /usr/lib/libpixman-1.so.0.24.0) ==2743== by 0x5B41629: pixman_image_create_bits (in /usr/lib/libpixman-1.so.0.24.0) ==2743== by 0x516AB62: _cairo_image_surface_create_with_pixman_format (cairo-image-surface.c:339) ==2743== by 0x516AE82: cairo_image_surface_create (cairo-image-surface.c:387) ==2743== by 0x6DED06B: cairo_png_trgt::obtain_surface(_cairo_surface*&) (in /tmp/synfigstudio-0.64.1-20131104.8.i386/lib/synfig/modules/libmod_png.so) ==2743== by 0x83C122A: AsyncTarget_Cairo::obtain_surface(_cairo_surface*&) (in /tmp/synfigstudio-0.64.1-20131104.8.i386/bin/synfigstudio) ==2743== by 0x4294CA3: synfig::Target_Cairo::render(synfig::ProgressCallback*) (in /tmp/synfigstudio-0.64.1-20131104.8.i386/lib/libsynfig.so.0.0.0) ==2743== by 0x83BE940: studio::AsyncRenderer::render_target() (in /tmp/synfigstudio-0.64.1-20131104.8.i386/bin/synfigstudio) ==2743== by 0x4F0DB07: call_thread_entry_slot (slot.h:440) ==2743== by 0x53C9A8E: ??? (in /lib/libglib-2.0.so.0.2800.6) ==2743== by 0x4679954: start_thread (pthread_create.c:300) ==2743==

Tested with synfigstudio-0.64.1-20131104.8.i386 using valgrind tool rendering a one minute test animation (just a circle moving) at 24 FPS (1441 frames).

EDIT: Same test with same version using PNG target instead shows no leak.

Yes.

Here you are Valgrind report. This is the worst because the amount of memory:

PNG export. Only two frames render.

<error>
  <unique>0x27df</unique>
  <tid>1</tid>
  <kind>Leak_DefinitelyLost</kind>
  <xwhat>
    <text>2,425,896 (15,300 direct, 2,410,596 indirect) bytes in 51 blocks are definitely lost in loss record 10,137 of 10,137</text>
    <leakedbytes>2425896</leakedbytes>
    <leakedblocks>51</leakedblocks>
  </xwhat>
  <stack>
    <frame>
      <ip>0x4028A28</ip>
      <obj>/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so</obj>
      <fn>malloc</fn>
      <dir>/build/valgrind-x3RsCO/valgrind-3.8.1/coregrind/m_replacemalloc</dir>
      <file>vg_replace_malloc.c</file>
      <line>270</line>
    </frame>
    <frame>
      <ip>0x4EF77B5</ip>
      <obj>/usr/lib/i386-linux-gnu/libcairo.so.2.11200.16</obj>
    </frame>
    <frame>
      <ip>0x4EF7BAE</ip>
      <obj>/usr/lib/i386-linux-gnu/libcairo.so.2.11200.16</obj>
    </frame>
    <frame>
      <ip>0x4EF7E7D</ip>
      <obj>/usr/lib/i386-linux-gnu/libcairo.so.2.11200.16</obj>
      <fn>cairo_image_surface_create</fn>
    </frame>
    <frame>
      <ip>0x42AEE69</ip>
      <obj>/usr/lib/i386-linux-gnu/libsynfig.so.0.0.0</obj>
      <fn>synfig::Target_Cairo_Tile::render(synfig::ProgressCallback*)</fn>
    </frame>
    <frame>
      <ip>0x82DDCAA</ip>
      <obj>/usr/bin/synfigstudio</obj>
      <fn>studio::AsyncRenderer::render_target()</fn>
    </frame>
    <frame>
      <ip>0x4DB3DE1</ip>
      <obj>/usr/lib/i386-linux-gnu/libglibmm-2.4.so.1.3.0</obj>
    </frame>
    <frame>
      <ip>0x5381C3D</ip>
      <obj>/lib/i386-linux-gnu/i686/cmov/libc-2.17.so</obj>
      <fn>clone</fn>
      <dir>/build/eglibc-an0j3i/eglibc-2.17/misc/../sysdeps/unix/sysv/linux/i386</dir>
      <file>clone.S</file>
      <line>131</line>
    </frame>
  </stack>
</error>

This is Cairo PNG render. Two frames too.

<error>
  <unique>0x2868</unique>
  <tid>1</tid>
  <kind>Leak_DefinitelyLost</kind>
  <xwhat>
    <text>1,964,152 (14,700 direct, 1,949,452 indirect) bytes in 49 blocks are definitely lost in loss record 10,259 of 10,260</text>
    <leakedbytes>1964152</leakedbytes>
    <leakedblocks>49</leakedblocks>
  </xwhat>
  <stack>
    <frame>
      <ip>0x4028A28</ip>
      <obj>/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so</obj>
      <fn>malloc</fn>
      <dir>/build/valgrind-x3RsCO/valgrind-3.8.1/coregrind/m_replacemalloc</dir>
      <file>vg_replace_malloc.c</file>
      <line>270</line>
    </frame>
    <frame>
      <ip>0x4EF77B5</ip>
      <obj>/usr/lib/i386-linux-gnu/libcairo.so.2.11200.16</obj>
    </frame>
    <frame>
      <ip>0x4EF7BAE</ip>
      <obj>/usr/lib/i386-linux-gnu/libcairo.so.2.11200.16</obj>
    </frame>
    <frame>
      <ip>0x4EF7E7D</ip>
      <obj>/usr/lib/i386-linux-gnu/libcairo.so.2.11200.16</obj>
      <fn>cairo_image_surface_create</fn>
    </frame>
    <frame>
      <ip>0x42AEE69</ip>
      <obj>/usr/lib/i386-linux-gnu/libsynfig.so.0.0.0</obj>
      <fn>synfig::Target_Cairo_Tile::render(synfig::ProgressCallback*)</fn>
    </frame>
    <frame>
      <ip>0x82DDCAA</ip>
      <obj>/usr/bin/synfigstudio</obj>
      <fn>studio::AsyncRenderer::render_target()</fn>
    </frame>
    <frame>
      <ip>0x4DB3DE1</ip>
      <obj>/usr/lib/i386-linux-gnu/libglibmm-2.4.so.1.3.0</obj>
    </frame>
    <frame>
      <ip>0x5381C3D</ip>
      <obj>/lib/i386-linux-gnu/i686/cmov/libc-2.17.so</obj>
      <fn>clone</fn>
      <dir>/build/eglibc-an0j3i/eglibc-2.17/misc/../sysdeps/unix/sysv/linux/i386</dir>
      <file>clone.S</file>
      <line>131</line>
    </frame>
  </stack>
</error>

With Cairo render there is a possible lost with a big amount:

<error>
  <unique>0x2869</unique>
  <tid>1</tid>
  <kind>Leak_PossiblyLost</kind>
  <xwhat>
    <text>7,372,800 bytes in 2 blocks are possibly lost in loss record 10,260 of 10,260</text>
    <leakedbytes>7372800</leakedbytes>
    <leakedblocks>2</leakedblocks>
  </xwhat>
  <stack>
    <frame>
      <ip>0x402A9B5</ip>
      <obj>/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so</obj>
      <fn>calloc</fn>
      <dir>/build/valgrind-x3RsCO/valgrind-3.8.1/coregrind/m_replacemalloc</dir>
      <file>vg_replace_malloc.c</file>
      <line>593</line>
    </frame>
    <frame>
      <ip>0x5BFFFE7</ip>
      <obj>/usr/lib/i386-linux-gnu/libpixman-1.so.0.32.4</obj>
    </frame>
    <frame>
      <ip>0x5C00085</ip>
      <obj>/usr/lib/i386-linux-gnu/libpixman-1.so.0.32.4</obj>
    </frame>
    <frame>
      <ip>0x4EF7B9C</ip>
      <obj>/usr/lib/i386-linux-gnu/libcairo.so.2.11200.16</obj>
    </frame>
    <frame>
      <ip>0x4EF7E7D</ip>
      <obj>/usr/lib/i386-linux-gnu/libcairo.so.2.11200.16</obj>
      <fn>cairo_image_surface_create</fn>
    </frame>
    <frame>
      <ip>0x82DFCA8</ip>
      <obj>/usr/bin/synfigstudio</obj>
      <fn>AsyncTarget_Cairo::obtain_surface(_cairo_surface*&amp;)</fn>
    </frame>
    <frame>
      <ip>0x82DDCAA</ip>
      <obj>/usr/bin/synfigstudio</obj>
      <fn>studio::AsyncRenderer::render_target()</fn>
    </frame>
    <frame>
      <ip>0x4DB3DE1</ip>
      <obj>/usr/lib/i386-linux-gnu/libglibmm-2.4.so.1.3.0</obj>
    </frame>
    <frame>
      <ip>0x5381C3D</ip>
      <obj>/lib/i386-linux-gnu/i686/cmov/libc-2.17.so</obj>
      <fn>clone</fn>
      <dir>/build/eglibc-an0j3i/eglibc-2.17/misc/../sysdeps/unix/sysv/linux/i386</dir>
      <file>clone.S</file>
      <line>131</line>
    </frame>
  </stack>
</error>

All the test was with Cairo activate in navigator and workspace. I can made a new testing desactivating all Cairo… but I think the problem is in rendering.

Yes. But only one. Mainly are vector objects made inside Synfig.

In my test there is leak in PNG export, too.

Is really strange.

Well, the PNG target DID show other leaks but not 750MB in size like the test with CairoPNG. Also I had cairo render disabled in workarea and navigator.

Attached valgrind output for both tests.
valgrind-3935-PNG.zip (248 KB)
valgrind-2743-CairoPNG.zip (247 KB)