go-gtk icon indicating copy to clipboard operation
go-gtk copied to clipboard

pixbuf memory leaks

Open raichu opened this issue 11 years ago • 4 comments

I'm trying to display an image, whose size adapts to window size. But after a few resizes, the memory usage reaches 1GB!

What is the proper way of loading a pixpuf, scaling it and putting in into an image object? The obvious way (just doing them in sequence) doesn't work even with Clear on image before changing the pixbuf of the image object.

gdk_pixbuf_unref and gdk_pixbuf_ref aren't exposed, so I don't think there is any way of preventing memory leaks from Go side. Maybe using SetFinalizer for pixbufs is a good way, along with adding Ref and Unref methods.

raichu avatar Aug 29 '13 05:08 raichu

Nope, calling Unref on the pixbuf returned by ScaleSimple after assinging it to the image worked!

raichu avatar Aug 29 '13 05:08 raichu

I checked a python implementation and it doesn't require to call Unref. Maybe it's indeed best to set finalizer Unref for all objects?

raichu avatar Aug 29 '13 05:08 raichu

I checked a python implementation and it doesn't require to call Unref. Maybe it's indeed best to set finalizer Unref for all objects?

Yes, currently you must call runtime.SetFinalizer if you want. But it's todo

mattn avatar Aug 29 '13 08:08 mattn

GdkPixbuf is inherit GObject. So you can call pb.Ref() or pb.Unref().

mattn avatar Dec 25 '14 08:12 mattn