Memory grows when opening many files in shell mode

Migrated from https://bugs.launchpad.net/inkscape/+bug/722229

Steps to reproduce:

for i in {1..10000}
do echo "file-open:SVG-logo.svg;export-filename:test.pdf;export-do;file-close";
done | inkscape --shell
  • Alternatively, shorten command to file-open:SVG-logo.svg;file-close
  • Windows, 0.92.x and older: for i in `seq 1 10000`; do echo "file-open:SVG-logo.svg;export-filename:test.pdf;export-do;file-close"; done | inkscape --shell

What happened?

  • slow memory leak (due to small file), memory use slowly rises with time
    • Started at 2.6% mem use in top, ends at 10% using steps to replicate.
  • another user experienced this exporting to pngs too. (replicated)
  • example file is just paths and clones and text. I still see mem increase just with paths (svg.svg), and yko on launchpad notes it happens with <?xml version="1.0" standalone="no"?> <svg xmlns="http://www.w3.org/2000/svg" version="1.1"> </svg>

At the low rate of growth it has, it may just be a memory leak that always happens, but is only noticeable with lots of file opens. Launchpad reporter notes that growth depends on size of svg.

What should have happened?

  • no memory leak

Sample attachments:

  • Original test case SVG-logo.svg
  • Just the paths svg.svg
  • Asan buid asan_mem_leaks.txt
  • memcheck output memleaksshell2.txt
  • Update: taking a look at the memcheck results, doesn't really look like a large memory leak is happening, but memory doesn't seem to be cleared early enough either.

Version Info:

  • Inkscape 0.47 r22583 (Apr 4 2010) Ubuntu 10.04.1 LTS
  • Inkscape 0.48+devel r10059 on OS X 10.5.8 i386
  • Inkscape 1.1-dev (8413cc40a8, 2020-08-29)
Edited by Nathan Lee
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information