From: <jc...@gm...> - 2015-01-08 16:40:32
|
Hi Kou, thank you very much for helping me. On 8 January 2015 at 14:50, Kouhei Sutou <ko...@co...> wrote: >> I have a general question about memory management: how is reference >> counting handled? For example, if I create a new object like this: >> >> a = Vips::Image.new >> >> and then get rid of the reference: >> >> a = nil >> GC.start >> >> I would expect the object to be unreffed. Is there some extra magic I need? > > No. You don't need to anything. > gobject-introspection gem (and glib2 gem) does everything. It doesn't seem to work for me. If I run: 10000.times do Vips::Image.new end GC.start I still have 10,000 GObjects, each with one ref. My code is here: https://github.com/jcupitt/ruby-vips8/blob/master/try/try2.rb#L98 Perhaps I am missing something in my loader class? Vips::image.new calls vips_image_new(), which just does g_object_new(): https://github.com/jcupitt/libvips/blob/master/libvips/iofuncs/image.c#L1681 John |