I'm not sure if this is a bug or something that I have done in the setup of Inkscape. I am running Inkscape 1.1.1 on Ubuntu 20.04 with 16GB RAM and an 8GB swap, which should be plenty. I have noticed that when I save (I save early and often) the RAM usage of my computer goes up, which is understandable while the saving is occurring, but after the file is saved, the RAM usage does not decrease. Even if I close the file, but not Inkscape, that RAM is still being used; I have to completely close Inkscape to get it back. This becomes problematic when working with some of my really large Inkscape files (10,000+ nodes) as two saves puts me close to an out-of-memory crash.
I didn't attach a screenshot (it would just show my maxed RAM) or sample file as this isn't a specific bug, but I can certainly provide either of these if necessary. The closest issue I could find is here, where someone was having this issue when trying to "Save As" .pdf; unfortunately the topic was closed without a definitive cause or solution.
Did a quick test with ~18K nodes on the Windows nightly build, but could not repro. I routinely work with pretty large files and haven't hit this problem AFAICT.
You might have to post this on the "inbox issues" and offer to supply a file (max is 10MB I think) that exhibits the problem. Requires a gitlab account, which is only the usual amount of hassle to set up.
Thanks for the responses Ron and Nathan. While I have not found a solution yet, I believe I have identified where the problem is coming from. I am saving ggplots from RStudio as PDFs with a dpi of 96. These plots are 896 columns created with geom_col and then coloured but no change to the alpha/opacity. When I import the PDF into Inkscape I noticed a couple things in the XML editor. First, the columns were all coming in as paths with 4 nodes instead of rectangles, is there a way to convert path to object (the reverse of object to path)? Second, the <svg:defs id="defs2"> contained some clipped paths (e.g., <svg:clipPath id="clipPath55">), each with a single nested path (<svg:path id="path53">), which I manually deleted in a text editor (I believe that's what you were suggesting in your other post, Nathan). However, that didn't do much. I have provided a sample of the PDF graph that I saved from RStudio that you can import into Inkscape to see what I'm talking about (my main figure has 16 of these graphs); I struggle to even ungroup all of the objects.
Hi, thanks for the extra info! While we're going through the full debugging, are you saving as a svg or a pdf here? I notice that the first time I save, RAM goes up, but after that the RAM doesn't increase as much. Since we partly use a garbage collector, that seems normal (though we don't always use it correctly so memory can leak).
Perhaps you have the Document Properties dialog open during a session? It's a known horror-show in terms of memory use in 1.1.x (fixed in upcoming development versions). I also recall a couple big leaks that were partly fixed but I can't remember what version they were introduced (so it might be helpful to upgrade to 1.1.2).
I replicate the struggle to ungroup (though I can't do much else unfortunately, I'm on 4 GB RAM). Looking at the file, it's an exceedingly normal file (ignoring the large number of paths) so I suspect we have a generic memory problem here.
Thanks for that detailed response, Nathan. I am currently using Inkscape 1.1.2 on Ubuntu 20.04 and the issue comes up when I'm trying to save as an .svg (I have attached a couple screenshots to demonstrate what's happening on my machine). In BashInk3 I have made a change but not saved it yet (notice the asterisk in the header), BashInk4 I have saved and you can see it used 3 GB of RAM, and in BashInk5 I have closed the file but not Inkscape and you can see my RAM is still being used.
I will keep an eye out and make sure I close the Document Properties dialog as soon as I'm finished with it (I'll also try to deal with all of that before importing anything as well). How about Themeing? I currently have Inkscape using my system theme (Adwaita-dark) and system icons (Humanity-Dark), could this be chewing up the memory?
Does the memory continue to increase on subsequent saves (by roughly the same amount)? (It doesn't look like it for me). If not, I'm afraid the memory growth on save is "expected" behavior.
After https://gitlab.com/inkscape/inkscape/-/issues/1794 was fixed, we save files by creating a copy of the svg and saving that. This creates the initial memory increase on save. Since subsequent saves increase the RAM by a smaller amount, this indicates that most (or all) or the memory is properly freed, and our Inkscape properly reuses it. However, after the memory increases, we do admittedly hold onto RAM unnecessarily (generally, memory is reserved in case it's needed again in the future, e.g. for future saves). This isn't a bug. It may be a consequence of our garbage collector (not entirely sure), which we are (very slowly) moving away from, so it may change in the future.
It might be worth adding a special case so we don't need to create a copy of the svg on save as an Inkscape SVG, though avoiding this RAM increase/extra work is the only benefit. (would need to create an issue in https://gitlab.com/inkscape/inbox/issues to track that request). Not sure if the added complexity is worth it since there are some modifications which need to be done on save even for Inkscape SVGs (specifically any SVG2 to SVG1.1 fallback code).
Note: for reference, I experienced a similar memory growth on open/close and on save with a svg file consisting on 32322 rectangles (5.8MB file) and the K_clusters file on 1.2 Inkscape 1.2-alpha1 (bc8db52380, 2022-03-23) Linux Mint 20. A similar pattern also happens with K_clusters and Inkscape 1.1.2 (ccedf6bf22, 2022-02-24) (didn't test the rectangles there)
Changing themeing is unlikely to help here (since the issue is with GBs of memory usage, and we're stuck using some theme anyway).
Yes, the memory growth continues through subsequent saves to the point where if I save my large .svg three times, I've hit an OOM and I guess since it's all RAM that is still in use by Inkscape, Linux can't dump it to the swap (my 8GB swap partition was never touched).
However, I will say that I think the situation was exacerbated by some poor coding on my part. Turns out I was writing bars on top of bars, which resulted in an average of 40 rectangles occupying the exact same space. Does it make sense that manipulating 40 objects all with the exact same coordinates/dimensions (but various fill colours) would take up more memory than the same 40 objects scattered about the workspace?
Either way, I have managed to make my figure workable (though slow) and so I really appreciate all the time and information you have given me. I would be happy to provide more files to you devs if you think it would help.
Odd, could you create an issue in inbox (inkscape.org/report) reporting this issue? For me each subsequent save only increased RAM by about 30MB (and I did at 6 saves in one test with 4GB RAM, and 2GB SWAP). The dialogs you have open and your preferences.xml file (usually stored in `~/.config/inkscape`). Anyway, glad that Inkscape's more usable now.
Well it seems that a recent update has solved the issue. The large file I showed you pictures of in my earlier post opens easily and uses less than 1GB of RAM (so I'm starting at 3.5GB used instead of the nearly 9GB I was starting at before) and many saves later I have only used another 1GB or so. It may have also been an Ubuntu issue, perhaps some libs were updated that no longer communicated properly with Inkscape.
Thanks again for walking me through all of this. I couldn't hope to get this kind of support dealing with Adobe Illustrator support staff.
I'm not sure if this is a bug or something that I have done in the setup of Inkscape. I am running Inkscape 1.1.1 on Ubuntu 20.04 with 16GB RAM and an 8GB swap, which should be plenty. I have noticed that when I save (I save early and often) the RAM usage of my computer goes up, which is understandable while the saving is occurring, but after the file is saved, the RAM usage does not decrease. Even if I close the file, but not Inkscape, that RAM is still being used; I have to completely close Inkscape to get it back. This becomes problematic when working with some of my really large Inkscape files (10,000+ nodes) as two saves puts me close to an out-of-memory crash.
I didn't attach a screenshot (it would just show my maxed RAM) or sample file as this isn't a specific bug, but I can certainly provide either of these if necessary. The closest issue I could find is here, where someone was having this issue when trying to "Save As" .pdf; unfortunately the topic was closed without a definitive cause or solution.
Thank you for any help with this,
Jeremy
Did a quick test with ~18K nodes on the Windows nightly build, but could not repro. I routinely work with pretty large files and haven't hit this problem AFAICT.
You might have to post this on the "inbox issues" and offer to supply a file (max is 10MB I think) that exhibits the problem. Requires a gitlab account, which is only the usual amount of hassle to set up.
I looked at the issue you linked, and I mentioned two issues that track all the problems found in the file before closing the issue.
Without a sample file from you, I can't tell if you're experiencing the same problem though.
Thanks for the responses Ron and Nathan. While I have not found a solution yet, I believe I have identified where the problem is coming from. I am saving ggplots from RStudio as PDFs with a dpi of 96. These plots are 896 columns created with geom_col and then coloured but no change to the alpha/opacity. When I import the PDF into Inkscape I noticed a couple things in the XML editor. First, the columns were all coming in as paths with 4 nodes instead of rectangles, is there a way to convert path to object (the reverse of object to path)? Second, the <svg:defs id="defs2"> contained some clipped paths (e.g., <svg:clipPath id="clipPath55">), each with a single nested path (<svg:path id="path53">), which I manually deleted in a text editor (I believe that's what you were suggesting in your other post, Nathan). However, that didn't do much. I have provided a sample of the PDF graph that I saved from RStudio that you can import into Inkscape to see what I'm talking about (my main figure has 16 of these graphs); I struggle to even ungroup all of the objects.
Thanks again for your time!
Hi, thanks for the extra info! While we're going through the full debugging, are you saving as a svg or a pdf here? I notice that the first time I save, RAM goes up, but after that the RAM doesn't increase as much. Since we partly use a garbage collector, that seems normal (though we don't always use it correctly so memory can leak).
Perhaps you have the Document Properties dialog open during a session? It's a known horror-show in terms of memory use in 1.1.x (fixed in upcoming development versions). I also recall a couple big leaks that were partly fixed but I can't remember what version they were introduced (so it might be helpful to upgrade to 1.1.2).
I replicate the struggle to ungroup (though I can't do much else unfortunately, I'm on 4 GB RAM). Looking at the file, it's an exceedingly normal file (ignoring the large number of paths) so I suspect we have a generic memory problem here.
Thanks for that detailed response, Nathan. I am currently using Inkscape 1.1.2 on Ubuntu 20.04 and the issue comes up when I'm trying to save as an .svg (I have attached a couple screenshots to demonstrate what's happening on my machine). In BashInk3 I have made a change but not saved it yet (notice the asterisk in the header), BashInk4 I have saved and you can see it used 3 GB of RAM, and in BashInk5 I have closed the file but not Inkscape and you can see my RAM is still being used.
I will keep an eye out and make sure I close the Document Properties dialog as soon as I'm finished with it (I'll also try to deal with all of that before importing anything as well). How about Themeing? I currently have Inkscape using my system theme (Adwaita-dark) and system icons (Humanity-Dark), could this be chewing up the memory?
Does the memory continue to increase on subsequent saves (by roughly the same amount)? (It doesn't look like it for me). If not, I'm afraid the memory growth on save is "expected" behavior.
After https://gitlab.com/inkscape/inkscape/-/issues/1794 was fixed, we save files by creating a copy of the svg and saving that. This creates the initial memory increase on save. Since subsequent saves increase the RAM by a smaller amount, this indicates that most (or all) or the memory is properly freed, and our Inkscape properly reuses it. However, after the memory increases, we do admittedly hold onto RAM unnecessarily (generally, memory is reserved in case it's needed again in the future, e.g. for future saves). This isn't a bug. It may be a consequence of our garbage collector (not entirely sure), which we are (very slowly) moving away from, so it may change in the future.
It might be worth adding a special case so we don't need to create a copy of the svg on save as an Inkscape SVG, though avoiding this RAM increase/extra work is the only benefit. (would need to create an issue in https://gitlab.com/inkscape/inbox/issues to track that request). Not sure if the added complexity is worth it since there are some modifications which need to be done on save even for Inkscape SVGs (specifically any SVG2 to SVG1.1 fallback code).
Note: for reference, I experienced a similar memory growth on open/close and on save with a svg file consisting on 32322 rectangles (5.8MB file) and the K_clusters file on 1.2 Inkscape 1.2-alpha1 (bc8db52380, 2022-03-23) Linux Mint 20. A similar pattern also happens with K_clusters and Inkscape 1.1.2 (ccedf6bf22, 2022-02-24) (didn't test the rectangles there)
Changing themeing is unlikely to help here (since the issue is with GBs of memory usage, and we're stuck using some theme anyway).
Yes, the memory growth continues through subsequent saves to the point where if I save my large .svg three times, I've hit an OOM and I guess since it's all RAM that is still in use by Inkscape, Linux can't dump it to the swap (my 8GB swap partition was never touched).
However, I will say that I think the situation was exacerbated by some poor coding on my part. Turns out I was writing bars on top of bars, which resulted in an average of 40 rectangles occupying the exact same space. Does it make sense that manipulating 40 objects all with the exact same coordinates/dimensions (but various fill colours) would take up more memory than the same 40 objects scattered about the workspace?
Either way, I have managed to make my figure workable (though slow) and so I really appreciate all the time and information you have given me. I would be happy to provide more files to you devs if you think it would help.
Odd, could you create an issue in inbox (inkscape.org/report) reporting this issue? For me each subsequent save only increased RAM by about 30MB (and I did at 6 saves in one test with 4GB RAM, and 2GB SWAP). The dialogs you have open and your preferences.xml file (usually stored in `~/.config/inkscape`). Anyway, glad that Inkscape's more usable now.
By the way, right now a developer has been working on stamping out some memory leaks (see https://gitlab.com/inkscape/inkscape/-/merge_requests/4263 and the issues linked in the description for what he has been working on).
Well it seems that a recent update has solved the issue. The large file I showed you pictures of in my earlier post opens easily and uses less than 1GB of RAM (so I'm starting at 3.5GB used instead of the nearly 9GB I was starting at before) and many saves later I have only used another 1GB or so. It may have also been an Ubuntu issue, perhaps some libs were updated that no longer communicated properly with Inkscape.
Thanks again for walking me through all of this. I couldn't hope to get this kind of support dealing with Adobe Illustrator support staff.
Keep up the good work!