<div dir="ltr"><div>Hi,</div><div><br></div><div>There have been a memory leak on win32 platform for a while because of the static __cairo_win32_device object that is never released (see <a href="https://bugs.freedesktop.org/show_bug.cgi?id=67171">https://bugs.freedesktop.org/show_bug.cgi?id=67171</a>)</div><div><br></div><div>Please find attached a simple patch that fixes the problem by adding a win32-specific cleanup call in the cairo_debug_reset_static_data function. I hope it can be added to the official release to remove the leak.</div><div><br></div><div>Regards,</div><div><br></div><div>Fred</div><div><br></div><div>Index: cairo-debug.c</div><div>===================================================================</div><div>--- cairo-debug.c<span class="" style="white-space:pre">       </span>(cairo-1.14.6)</div><div>+++ cairo-debug.c<span class="" style="white-space:pre">    </span>(working copy)</div><div>@@ -89,7 +89,9 @@</div><div> #if CAIRO_HAS_DRM_SURFACE</div><div>     _cairo_drm_device_reset_static_data ();</div><div> #endif</div><div>-</div><div>+#if CAIRO_HAS_WIN32_SURFACE</div><div>+    _cairo_win32_device_reset_static_data ();</div><div>+#endif</div><div>     _cairo_default_context_reset_static_data ();</div><div> </div><div> #if CAIRO_HAS_COGL_SURFACE</div><div>Index: cairoint.h</div><div>===================================================================</div><div>--- cairoint.h<span class="" style="white-space:pre">       </span>(cairo-1.14.6)</div><div>+++ cairoint.h<span class="" style="white-space:pre">       </span>(working copy)</div><div>@@ -442,6 +442,11 @@</div><div> cairo_private void</div><div> _cairo_win32_font_reset_static_data (void);</div><div> </div><div>+#if CAIRO_HAS_WIN32_SURFACE</div><div>+cairo_private void</div><div>+_cairo_win32_device_reset_static_data (void);</div><div>+#endif</div><div>+</div><div> #if CAIRO_HAS_COGL_SURFACE</div><div> void</div><div> _cairo_cogl_context_reset_static_data (void);</div><div>Index: win32/cairo-win32-device.c</div><div>===================================================================</div><div>--- win32/cairo-win32-device.c<span class="" style="white-space:pre">    </span>(cairo-1.14.6)</div><div>+++ win32/cairo-win32-device.c<span class="" style="white-space:pre">       </span>(working copy)</div><div>@@ -187,3 +187,12 @@</div><div> </div><div>     return flags;</div><div> }</div><div>+</div><div>+void _cairo_win32_device_reset_static_data (void)</div><div>+{</div><div>+     if (__cairo_win32_device != NULL) {</div><div>+<span class="" style="white-space:pre">      </span>cairo_device_t *device = __cairo_win32_device;</div><div>+<span class="" style="white-space:pre">    </span>__cairo_win32_device = NULL;</div><div>+<span class="" style="white-space:pre">      </span>cairo_device_destroy (device);</div><div>+    }</div><div>+}</div><div><br></div></div>