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 133681 - memory leak in gdk.drawable.get_image
memory leak in gdk.drawable.get_image
Product: pygobject
Classification: Bindings
Component: codegen
Other All
: Normal normal
: ---
Assigned To: Python bindings maintainers
Python bindings maintainers
Depends on:
Reported: 2004-02-06 20:55 UTC by John D. Hunter
Modified: 2008-07-16 10:13 UTC
See Also:
GNOME target: ---
GNOME version: ---

Description John D. Hunter 2004-02-06 20:55:44 UTC
A user of matplotlib reported a memory leak in a pygtk application.

I tracked it down to a call to memory leak in gdk.drawable.get_image.  Not
knowing too much about pygtk codegen, it appears that this bug is similar to 
bug 129754.  By adding   (caller-owns-return #t) to (define-method get_image
  (of-object "GdkDrawable") in gdk.defs, the memory leak disappears.

(define-method get_image
  (of-object "GdkDrawable")
  (c-name "gdk_drawable_get_image")
  (return-type "GdkImage*")
    '("gint" "x")
    '("gint" "y")
    '("gint" "width")
    '("gint" "height")
  (caller-owns-return #t)

Here is a pygtk script that exposes the bug

import pygtk
import gtk

def expose_event(widget, event):

    def repeat(*args):
        print 'drawing', repeat.cnt
        repeat.cnt += 1
        imgBack = widget.window.get_image(10, 10, 50, 50)

        return gtk.TRUE
    repeat.cnt = 0
    gtk.timeout_add(20, repeat)
    return gtk.TRUE

win = gtk.Window()
win.connect('delete_event', gtk.mainquit)

da = gtk.DrawingArea()
da.connect('expose_event', expose_event)


Comment 1 Gustavo Carneiro 2004-02-23 20:59:16 UTC
Committed your suggested fix.  Thanks! :-)