memory leak in desktop-style.cpp

Bug #1275170 reported by David Mathog
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Low
David Mathog

Bug Description

This patch closes a memory leak that passes through desktop-style.cpp. It showed up in valgrind. A very little fish from a long day of fishing!

I was looking for leaks I might have introduced with the changes I have been working on. Found a couple of minor ones in my code and fixed those (it isn't in trunk yet, so no point posting them here), but it was extremely difficult since opening the program, doing not much of anything, and closing it, results in a 0.5M line valgrind log, with 49511 loss records.

There is a really nasty set of leaks associated with nr-style.cpp/h that I could not successfully repair. Apparently there are lines of execution which pass through drawing-text.cpp/drawing-shape.cpp and store things in one or more of the 5 pointer fields of an NRStyle object. In theory when the DrawingText or DrawingShape object goes away its destructor should clean these out. In practice many of them persist all the way until Inkscape exits. I tried adding an _nrstyle.clean() method, basically just what is already in the destructor, plus code to set the pointers to NULL after emptying their contents, and placed it at the end of the methods that call appply/prepareFill()/Stroke(), ie, the ones that actually draw things. That "fixed" the memory leak, but it made the drawing surface unstable. For instance, zooming in or out made things disappear. So that approach isn't going to fly. It wasn't a comprehensive fix in any case, since the objects that included the problem NRStyle objects were not removed. (This broken fix is not part of the current patch.)

Revision history for this message
David Mathog (mathog) wrote :
su_v (suv-lp)
tags: added: code-quality performance
jazzynico (jazzynico)
tags: added: code-design
removed: code-quality
Revision history for this message
Kris (kris-degussem) wrote :

Thanks for sharing this fix.
Committed in trunk revision 13013.

Changed in inkscape:
status: New → Triaged
importance: Undecided → Low
assignee: nobody → David Mathog (mathog)
milestone: none → 0.91
status: Triaged → Fix Committed
Revision history for this message
Kris (kris-degussem) wrote :

Follow up: the same memory leak apparently also exist in:
- src/extension/internal/javafx-out.cpp:399
- src/sp-conn-end-pair.cpp:175
- src/uri-references.cpp:69

will have a look later on to create a patch for these ones.

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

Patch for the other similar memory leaks.
(nitting: first case could have bee handled better by not using the string class, but at least the leak is fixed)

Changed in inkscape:
status: Fix Committed → In Progress
Revision history for this message
Kris (kris-degussem) wrote :

Leaks reported in previous comment fixed in r13105.

Changed in inkscape:
status: In Progress → Fix Committed
Bryce Harrington (bryce)
Changed in inkscape:
status: Fix Committed → Fix Released
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.