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 674092 - [Patch] memory leak in _wrap_pango_cairo_create_layout
[Patch] memory leak in _wrap_pango_cairo_create_layout
Status: RESOLVED DUPLICATE of bug 660216
Product: pygtk
Classification: Bindings
Component: pango
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
: 625287 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-04-14 05:37 UTC by wzssyqa
Modified: 2013-04-05 18:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
suggested patch (823 bytes, patch)
2013-04-04 13:57 UTC, Matěj Cepl
none Details | Review

Description wzssyqa 2012-04-14 05:37:58 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 *
Comment 1 wzssyqa 2012-04-14 05:41:30 UTC
This patch is given by "王勇"<wangyong@linuxdeepin.com>;
Comment 2 shitsu16 2012-08-30 08:45:53 UTC
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.
Comment 3 Pacho Ramos 2013-01-13 11:21:23 UTC
Any news here? Could the patch at least be reviewed by upstream to know if it's ok to be applied downstream?
Comment 4 Hubert Figuiere (:hub) 2013-04-04 13:37:22 UTC
(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.
Comment 5 Matěj Cepl 2013-04-04 13:57:58 UTC
Created attachment 240610 [details] [review]
suggested patch
Comment 6 Matěj Cepl 2013-04-04 13:59:21 UTC
(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?
Comment 7 Hubert Figuiere (:hub) 2013-04-04 14:18:40 UTC
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.
Comment 8 Ma Hsiao-chun 2013-04-04 16:52:06 UTC
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
Comment 9 Federico Mena Quintero 2013-04-05 18:15:06 UTC
*** Bug 625287 has been marked as a duplicate of this bug. ***
Comment 10 Federico Mena Quintero 2013-04-05 18:18:51 UTC
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 ***