Ruby Forum Ruby-Gnome 2 > Gdk::Pixbuf#from_drawable Memory Leak?

Posted by Andy Chantrill (Guest)
on 14.10.2006 04:45
(Received via mailing list)
Hey,

I have been having problems with using Gdk::Pixbuf#from_drawable - it
seems to leak memory (see example below).

Is this a (known) bug? Is there a patch/workaround?

Regards,
Andy.


require 'gtk2'
require 'gtkmozembed'

Gtk.init

gtk = Gtk::Window.new

moz = Gtk::MozEmbed.new
moz.set_chrome_mask(Gtk::MozEmbed::ALLCHROME)

gtk.add(moz)
gtk.maximize
gtk.show_all

moz.load_url("http://www.google.com/")

Gtk::timeout_add(1000) do
        x, y, width, height, depth = gtk.window.geometry

        pixbuf = Gdk::Pixbuf.from_drawable(nil, gtk.window, 0, 0, width,
height)
        pixbuf = pixbuf.scale(640, 400, Gdk::Pixbuf::INTERP_BILINEAR)
        pixbuf.save("foo.png", "png")

        GC.start # This doesn't help :(

        true
end

Gtk.main


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, 
security?
Get stuff done quickly with pre-integrated technology to make your job 
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache 
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Posted by Kouhei Sutou (Guest)
on 14.10.2006 06:41
(Received via mailing list)
Hi,

In <45304EF4.8070003@plaggypig.co.uk>
  "[ruby-gnome2-devel-en] Gdk::Pixbuf#from_drawable Memory Leak?" on 
Sat, 14 Oct 2006 03:44:04 +0100,
  Andy Chantrill <andy@plaggypig.co.uk> wrote:

> I have been having problems with using Gdk::Pixbuf#from_drawable - it 
> seems to leak memory (see example below).

Thanks for reporting a bug. I fixed in CVS.

> Is this a (known) bug? Is there a patch/workaround?

Try the attached patch.

Thanks,
Posted by Andy Chantrill (Guest)
on 14.10.2006 18:17
(Received via mailing list)
Hey,

Many thanks - your patch has fixed it. :-)

Regards,
Andy.

Kouhei Sutou wrote:

>>    
>Try the attached patch.
>RCS file: /cvsroot/ruby-gnome2/ruby-gnome2/gtk/src/rbgdkpixbuf.c,v
>+            g_object_unref(buf);
>Get stuff done quickly with pre-integrated technology to make your job easier
>
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, 
security?
Get stuff done quickly with pre-integrated technology to make your job 
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache 
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642