GNOME Bugzilla – Bug 709264
Fix memory leaks in icons handling
Last modified: 2013-10-02 15:23:10 UTC
The background panel makes heavy use of loadable icons, and this causes leaks as big as each of the icons each time they're rendered.
Created attachment 256262 [details] [review] icon-theme: Use g_clear_* helpers in finalize
Created attachment 256263 [details] [review] icon-theme: Fix 2 memory leaks in GtkIconInfo
Created attachment 256264 [details] [review] iconhelper: Use g_clear_* helpers
Created attachment 256265 [details] [review] iconhelper: Fix leak when rendering to cairo surface
Review of attachment 256262 [details] [review]: looks good
Review of attachment 256263 [details] [review]: looks good.
Review of attachment 256264 [details] [review]: this is not really needed, except for dropping some code. on the other hand, it's a finalize() implementation.
Review of attachment 256265 [details] [review]: looks good.
in general, I think we need to clear up that g_clear_object/pointer are needed not for reducing lines of code, but for atomic access to clear a pointer. GTK+ does not really need that, as we assume that all GTK+ code is called from the same thread (stuff will blow up if that's not the case, so a leak would be the least of our worries), and atomic operations are not exactly cheap. on the other hand, we're already using g_clear_* everywhere, so it's not like it's going to be worse than what we already have.
(In reply to comment #9) > in general, I think we need to clear up that g_clear_object/pointer are needed > not for reducing lines of code, but for atomic access to clear a pointer. I use it to reduce lines of code, because it's super convenient. We're really not going to gain speedups by dropping the atomics -- the free(); is 20 times more expensive than atomics. Allocate smarter if you want to speed up your code.
Pushed the icon-theme fixes to gtk-3-8, and all the fixes to gtk-3-10 and master. Attachment 256262 [details] pushed as 7c595bc - icon-theme: Use g_clear_* helpers in finalize Attachment 256263 [details] pushed as 8938f3c - icon-theme: Fix 2 memory leaks in GtkIconInfo Attachment 256264 [details] pushed as e53bb1b - iconhelper: Use g_clear_* helpers Attachment 256265 [details] pushed as 744b790 - iconhelper: Fix leak when rendering to cairo surface