Memory leak on ruby gtk-3 -
i'm experiencing memory leak on ruby 2.3.1 gtk-3. on system (ubuntu 16-04) following code consumes approximately 80 mb. size of picture.jpg 289kb.
`require 'gtk3'
def ptest i=0 j=0 loop { += 1 j += 1 exit if j==50 @image = gtk::image.new newpixbuf = gdkpixbuf::pixbuf.new(:file => "picture.jpg") @image.pixbuf = newpixbuf @image.clear @image=nil if == 10 p "gc" gc.start = 0 end } end ptest` according https://sourceforge.net/p/ruby-gnome2/mailman/message/8659687/ shouldn't happen. can release memory?
i'm not ruby know bits of gtk+. in c, must deal memory allocations yourself, need unref pixbuf.
from gtkimage documentation:
the gtkimage not assume reference pixbuf; still need unref if own references.
so, probably, if ruby doesn't implement arc (automatic reference counting on gobjects), must newpixbuf.unref (not sure ruby syntax) right after @image.pixbuf = newpixbuf.
hope helps.
Comments
Post a Comment