Memory leak when showing/hiding embedded images.

Bug #597689 reported by Drax
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Inkscape
Confirmed
Medium
Unassigned

Bug Description

Hiding and showing a layer containing only an embedded image causes the memory usage to spike uncontrollably. When the image is linked instead of embedded, this issue does not occur.

Steps to reproduce:
1. Create a new document.
2. Embed an image in the document.
3. Open Task Manager.
4. On the 'Performance' tab, take note of memory usage.
5. In Inkscape, repeatedly show and hide the layer containing the embedded image.

The memory usage climbs each time the image is shown. This can climb at rates up to 150MB each time it is shown, when working with large images. Eventually, the RAM will be completely consumed by Inkscape and can cause system instability. Closing Inkscape releases the memory.

This was tested on Windows Vista Home Basic, with 2 GB RAM. This was tested on 0.47-3 and 0.48pre1-1.

When watching the memory info in Inkscape, the 'libgc - In Use' is what increases.

Revision history for this message
su_v (suv-lp) wrote :

Could you add information about your OS and Inkscape version?

Revision history for this message
su_v (suv-lp) wrote :

not reproduced with Inkscape 0.47 and 0.47+devel r9529 on OS X 10.5.8

If you work an a Windows platform with Inkscape 0.47, your observation is possibly related to bug #221712 “GDI object leak in Pango hangs Inkscape after some time” (see comment #20: "I was able to reproduce this crash simply by hiding and unhiding a layer within my image. It does not seem to matter which layers I hide, but more GDI objects are consumed with more objects hidden/unhidden in the canvas.")

Revision history for this message
Drax (drax89) wrote :

I've uploaded a DxDiag of this machine, and I included some extra details in the bug info.

description: updated
su_v (suv-lp)
tags: added: bitmap win32
removed: embed embedded leak
Revision history for this message
jazzynico (jazzynico) wrote :

Not really reproduced on Vista, Inkscape 0.47 and r9530.
I see an increase in memory usage (about the size of the image each time the layer visibility is toggled), but it quickly goes back to (almost) its initial value. Did you try to click the recalculate button in the Inkscape About memory dialog?

Changed in inkscape:
importance: Undecided → Low
status: New → Incomplete
Revision history for this message
Drax (drax89) wrote :

Recalculating in Inkscape does not seem to do anything at all.

I've now tried this with three different images.

6427x4065 JPEG - Constant increase in memory by about 30 MB per show/hide.
1158x800 JPEG - No noticable increase.
3452x4050 PNG - Up to 60~70MB per show/hide. This is the image that made me write the issue in the first place.

I don't have the ability to test multiple image sizes and types right now, but I can say that it has definitely got something to do with large PNG files. As previously stated, linking to this PNG causes no increase whatsoever.

Revision history for this message
su_v (suv-lp) wrote :

reproduced with Inkscape 0.47+devel r9529 on OS X 10.5.8

test images (random choice from DA):
how_to__lineart_with_inkscape_by_happyline.png
8.5 MB (8'953'640 bytes)
2000 × 3840 pixels
95 pixels/inch
sRGB IEC61966-2.1

CvS_Vector_Tutorial_001_by_leeinlimbo.png
7.3 MB (7'611'366 bytes)
1200 × 11140 pixels
72.01 pixels/inch
sRGB IEC61966-2.1

tutorial_vector_art__photoshop_by_AndersonMathias.jpg
7.6 MB (8'015'609 bytes)
2224 × 11500 pixels
96 pixels/inch
sRGB IEC61966-2.1

Memory consumption is increasing with each hide/show cycle of the layer containing the embedded image, though with above images in the range of 5/10 MB when hiding and 10/30 MB when showing the layer. Memory is not released after deleting the embedding image or closing the document window.

repeated console messages (with varying size depending on image):
** (inkscape-bin:56339): WARNING **: GC Warning: Repeated allocation of very large block (appr. size 12328960):
 May lead to memory leak and poor performance.

Not reproduced with linked images.

Revision history for this message
su_v (suv-lp) wrote :

Raising importance to 'Medium'.

Should this be of higher or even critical concern considering that embedding images is the default for 0.48?

Changed in inkscape:
importance: Low → Medium
status: Incomplete → Confirmed
tags: added: performance
removed: win32
Revision history for this message
Henri Laurie (henri-laurie) wrote :

Hi---I am adding myself as an affected person, and I could mention a colleague so really I would like to add two more affected people.

Seems to be across systems---I am running Ubuntu 10.04 and she is running OSX Snow Leopard, recent version.

Seems to be due to SVG files she recently created on the new Mac. Both of us experience huge CPU uses (near 100 percent), memory hog (both my RAM and my swap directory fill up, can't say about Mac but despite high spec mac it takes several minutes to proces file eg to ungroup, saving to svg is fairly quick, exporting to .eps is extremely slow).

The input file is not that large, just 2.8 MB. Not sure if its origin is relevant, but it was created using a save option on the mac, the original image made by a home-grown java applet. Am willing to share it if it will help. Henri

Revision history for this message
Henri Laurie (henri-laurie) wrote :

It gets worse. After the test above, inkscape didn't shut down properly, up came the dialogue box warning me of it, and I clicked 'force quit'.

Now there's rogue process on my system: backend is running, with root privileges, and when I sudo kill the message comes back that there is no such process!

I wonder if it will survive a mere logout---will test and report.

Revision history for this message
Henri Laurie (henri-laurie) wrote :

Yes, it does. Even after logging out and logging back in, there is a process using about 100 percent of cpu, according to top, which gives the command name as backend and the owner as root.

Curiously, the rogue process has a changed PID. Will restart computer and report.

Revision history for this message
Henri Laurie (henri-laurie) wrote :

Yes. Rogue process gone.

Revision history for this message
su_v (suv-lp) wrote :

Henri Laurie wrote
> it takes several minutes to proces
> file eg to ungroup, saving to svg is fairly
> quick, exporting to .eps is extremely slow

This does not seem related to this bug (#597689) which is a specific issue with embedded bitmap images and toggling the visibility of the layer they are in.

I propose you file a separate report, adding version information about both OS and Inkscape versions used, as well as attaching the file and possibly providing more details about how it was created (explaining what 'using a save option on the mac' means - an option of osx-native applications to save as SVG or PDF? Or a 'Save' option of the home-grown java applet? If so, does the java applet use Batik to handle SVG?)

Revision history for this message
Henri Laurie (henri-laurie) wrote :

Sorry to clog the space, wasn't sure what counted as embedded. Will get together with colleague (not before tomorrow) to file bug report, it is new to us but we use inkscape rarely so cannot say whether it is a bug in the app or elsewhere---but it's occurence in two OS points to the app, I think. Thanks for responses and in general all the efforts, I liked inkscape a lot and we used it in this case even with the performance issues.

tags: removed: memory
Revision history for this message
Kris (kris-degussem) wrote :

I think the underlying issue is the same as Bug #414413 and hence that it is a duplicate.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.