From: nobu@... Date: 2014-09-16T02:04:22+00:00 Subject: [ruby-core:65054] [ruby-trunk - Bug #10244] [Third Party's Issue] Garbage Collector not being triggered Issue #10244 has been updated by Nobuyoshi Nakada. Status changed from Open to Third Party's Issue Michel Boaventura wrote: > I'm trying to understand why this simple script doesn't trigger a single run of the GC and eats all memory: > > ```Ruby > require 'gdk3' > > loop do > Gdk::Pixbuf.new('foo.png') > end > ``` Ruby doesn't know about memories `malloc`ed inside gdk library, so they can't trigger GC. > ```Ruby > puts GC.stat[:count] if (i / 100).zero? > ``` You might want to write `(i % 100)`? ---------------------------------------- Bug #10244: Garbage Collector not being triggered https://bugs.ruby-lang.org/issues/10244#change-48923 * Author: Michel Boaventura * Status: Third Party's Issue * Priority: Normal * Assignee: * Category: core * Target version: * ruby -v: ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- Hi all, I'm trying to understand why this simple script doesn't trigger a single run of the GC and eats all memory: ```Ruby require 'gdk3' loop do Gdk::Pixbuf.new('foo.png') end ``` Changing it just a little to print ```Ruby GC.stat[:count]``` shows a constant value always: ```Ruby require 'gdk3' i = 0 loop do i += 1 Gdk::Pixbuf.new('foo.png') puts GC.stat[:count] if (i / 100).zero? end ``` Moreover, if I manually run it, then the memory usage stays constant: ```Ruby require 'gdk3' loop do Gdk::Pixbuf.new('foo.png') GC.start end ``` I understant that this is probably a gdk3 issue, but what is puzzling me is why GC isn't running automatically but if I start it manually everything works just fine. Thank you! -- https://bugs.ruby-lang.org/