Inkscape leaking memory when saving document when large PNG image is linked
Summary:
Just randomly was working on a file, and had a large PNG in the background. When I randomly happened to open up Task Manager, noticed Inkscape was using up over 1GB of memory!
So, did some testing to figure out why this was the case and discovered that for some odd reason, Inkscape was leaking around 14,800 K every time I saved the file! That adds up if you're saving constantly to make sure you don't lose anything due to a possible crash (like if Inkscape completely freezes up on Windows or your power randomly goes out).
Also tested a version of the file without the image attached, and it didn't have this leak, so that's how I narrowed it down to being due to the PNG being linked to the file.
Steps to reproduce:
- Open the attached file Inkscape (zipped due to attached PNG file for reproduction). leak_tester_1.7z
- Open Task Manger and (if you only have 1 monitor) put it in "Always on Top" mode so you can watch the memory increase.
- Not sure if this matters, but make sure you have Inkscape maximized to full screen (1920x1018), and the zoom of the file is at 128%.
- Once Inkscape is open, select the only drawing in the file, a 'm'. (Memory usage should be around 98,788 K.)
- Enter node editing mode (F2), and hit 'Tab' to select the first node. (99,496 K)
- Change the 'X' coordinates from 1100.250 to 1100.000. (99,540 K)
- Ctrl+S (114,420 K)
- Now, 'tab' to the 2nd node in the file (should be x1131.500 y680.000). (114,404 K)
- Change the 'X' coordinates from 1131.500 to 1131.000. (114,552 K)
- Ctrl+S (129,320 K)
What happened?
Every time you save the document, the memory increases ~14,800 K.
What should have happened?
Memory doesn't increase that much (like 20 K tops, similar to 1.0.2).
I tested the same file in 1.0.2-2 (e86c870879, 2021-01-15) x64
, and here's the memory usage in it on the same steps as above:
- 98,912 K
- 99,588 K
- 135,784 K (this is a weird jump up that isn't present in 1.1, so, I'd ignore it since it isn't related to the saving leak)
- 135,828 K
- 136,152 K
- 137,052 K
- 137,060 K
So, as you can see, 1.0.2 doesn't have this same issue of jumping up a lot of memory per save, so it's something that happened in the 1.1 branch.
NOTE: Both sets of memory usage was done with fresh profiles to rule out any issue with my normal one.
Version info
Inkscape 1.1 (c68e22c387, 2021-05-23) x64
Windows 7 SP1 x64