GNOME Bugzilla – Bug 562574
Pangocariowin32 is leaking every cairo font it ever creates
Last modified: 2010-01-30 19:10:55 UTC
Since revision 2347 (2007-06-12) aka. pango-1-18 there is a missing a call to cairo_scaled_font_destroy() in pangocairo-win32font.c which causes an unbound GDI-Object leak.
Given that GDI-Objects apparently are limited to 10000 per process this causes quite a fast death for a font intensive application. (I noticed with Dia using a diagram with many UML classes and zooming around.)
The following patch fixes the issue for me. I think something similar should be applied to all branches still in use.
--- D:/devel/from-svn/pango/pango/pangocairo-win32font.c (revision 2741)
+++ D:/devel/from-svn/pango/pango/pangocairo-win32font.c (working copy)
@@ -164,6 +164,13 @@
pango_cairo_win32_font_finalize (GObject *object)
+ PangoCairoWin32Font *cwfont = (PangoCairoWin32Font *) object;
+ cairo_scaled_font_t *scaled_font = _pango_cairo_font_private_get_scaled_font (&PANGO_CAIRO_WIN32_FONT (object)->cf_priv);
+ if (scaled_font)
+ cairo_scaled_font_destroy (scaled_font);
G_OBJECT_CLASS (pango_cairo_win32_font_parent_class)->finalize (object);
Hans, seems like the win32 and atsui pangocairo backends were not finalizing correctly. No idea how this stumbled. Anyway. Committed the fix. Please test.
Adding rhult to test the atsui change (so at least it builds :)).
2008-11-28 Behdad Esfahbod <firstname.lastname@example.org>
Bug 562574 – Pangocariowin32 is leaking every cairo font it ever
* pango/pangocairo-atsuifont.c (pango_cairo_atsui_font_finalize):
* pango/pangocairo-win32font.c (pango_cairo_win32_font_finalize):
Finalize shared pangocairo font resources. Oops!
* pango/pangocairo-font.c (_pango_cairo_font_private_finalize):
Protect against multiple calls to finalize. This is practiced by the
pangocairo-fcfont when a font is shutdown and then finalized.
Eek and oops! Thanks for catching this. I've just tested the change, builds and works fine.
works fine on win32, too.
*** Bug 543209 has been marked as a duplicate of this bug. ***