GNOME Bugzilla – Bug 674092
[Patch] memory leak in _wrap_pango_cairo_create_layout
Last modified: 2013-04-05 18:18:51 UTC
if didn't unref after pygobject_new. while(1): a=pango_cairo.create_layout() may cause, memory run out: python doesn't GC this memory. The patch is: Index: pygtk-2.24.0/pangocairo.override =================================================================== --- pygtk-2.24.0.orig/pangocairo.override 2012-04-14 01:40:59.568703232 +0800 +++ pygtk-2.24.0/pangocairo.override 2012-04-14 01:41:05.792703324 +0800 @@ -119,10 +119,15 @@ _wrap_pango_cairo_create_layout(PyGObject *self) { PangoLayout *ret; + PyObject *py_ret; ret = pango_cairo_create_layout(PycairoContext_GET(self)); /* pygobject_new handles NULL checking */ - return pygobject_new((GObject *)ret); + py_ret = pygobject_new((GObject *) ret); + if (ret) { + g_object_unref(ret); + } + return py_ret; } static PyObject *
This patch is given by "王勇"<wangyong@linuxdeepin.com>;
looks like https://bugzilla.gnome.org/show_bug.cgi?id=625287 https://bugzilla.gnome.org/show_bug.cgi?id=660216 also this bug. patch works for me, thanks.
Any news here? Could the patch at least be reviewed by upstream to know if it's ok to be applied downstream?
(In reply to comment #3) > Any news here? Could the patch at least be reviewed by upstream to know if it's > ok to be applied downstream? There is no patch attached. So if you want it to be review the first step is to attach it.
Created attachment 240610 [details] [review] suggested patch
(In reply to comment #4) > There is no patch attached. So if you want it to be review the first step is to > attach it. Better?
I'm not the maintainer. So I can't say. (*hint*: I don't even use Python) Just that when people argue a patch is not reviewed when there is no patch attached, well, they shouldn't wonder why... I think somebody else on d-d-l pointed out the maintenance status of this module.
Isn't OP or the patch obvious for those who understand reference counting? If you want a test ground, try Linux Deepin [1], this is where the patch come from and the distro ships PyGTK with this patch applied. http://distrowatch.com/deepin
*** Bug 625287 has been marked as a duplicate of this bug. ***
Thanks to the original reporter for the patch, and to Matěj for making it an attachment. I'm marking this bug as a duplicate of #660216, as that one has a similar fix from Owen Taylor along with two other leak fixes. The patches for create_layout() are equivalent. *** This bug has been marked as a duplicate of bug 660216 ***