After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 562574 - Pangocariowin32 is leaking every cairo font it ever creates
Pangocariowin32 is leaking every cairo font it ever creates
Product: pango
Classification: Platform
Component: win32
Other Windows
: Normal critical
: ---
Assigned To: gtk-win32 maintainers
: 543209 (view as bug list)
Depends on:
Reported: 2008-11-28 15:02 UTC by Hans Breuer
Modified: 2010-01-30 19:10 UTC
See Also:
GNOME target: ---
GNOME version: ---

Description Hans Breuer 2008-11-28 15:02:38 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.

Index: D:/devel/from-svn/pango/pango/pangocairo-win32font.c
--- 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 @@
 static void
 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);
Comment 1 Behdad Esfahbod 2008-11-28 17:24:28 UTC
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  <>

        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.

Comment 2 Richard Hult 2008-11-28 18:04:34 UTC
Eek and oops! Thanks for catching this. I've just tested the change, builds and works fine.

Comment 3 Hans Breuer 2008-11-28 20:33:17 UTC
works fine on win32, too.
Comment 4 Hans Breuer 2010-01-30 19:10:55 UTC
*** Bug 543209 has been marked as a duplicate of this bug. ***