# Gdk::Pixbuf#from\_drawable Memory Leak?

**URL:** <https://www.ruby-forum.com/t/gdk-pixbuf-from-drawable-memory-leak/72099>\
**Category:** Ruby-Gnome 2\
**Created:** [October 14, 2006, 4:45am UTC](https://www.ruby-forum.com/t/gdk-pixbuf-from-drawable-memory-leak/72099 "2006-10-14T04:45:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![andy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@andy](https://www.ruby-forum.com/u/andy)\
**Post date:** [October 14, 2006, 4:45am UTC](https://www.ruby-forum.com/t/gdk-pixbuf-from-drawable-memory-leak/72099/1 "2006-10-14T04:45:07Z")

</div>

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/](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](http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642)

---

<div class="post-metadata">

**Author:** ![andy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@andy](https://www.ruby-forum.com/u/andy)\
**Post date:** [October 14, 2006, 6:41am UTC](https://www.ruby-forum.com/t/gdk-pixbuf-from-drawable-memory-leak/72099/2 "2006-10-14T06:41:12Z")

</div>

Hi,

In [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
“[ruby-gnome2-devel-en] Gdk::Pixbuf#from\_drawable Memory Leak?” on  
Sat, 14 Oct 2006 03:44:04 +0100,  
Andy C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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,

---

<div class="post-metadata">

**Author:** ![andy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/aeb1de/32.png) [@andy](https://www.ruby-forum.com/u/andy)\
**Post date:** [October 14, 2006, 6:17pm UTC](https://www.ruby-forum.com/t/gdk-pixbuf-from-drawable-memory-leak/72099/3 "2006-10-14T18:17:56Z")

</div>

Hey,

Many thanks - your patch has fixed it. 🙂

Regards,  
Andy.

Kouhei S. 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](http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642)
