go-gtk
go-gtk copied to clipboard
pixbuf memory leaks
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.
Nope, calling Unref on the pixbuf returned by ScaleSimple after assinging it to the image worked!
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?
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
GdkPixbuf is inherit GObject. So you can call pb.Ref() or pb.Unref().