Bug #10244
closedGarbage Collector not being triggered
Description
Hi all,
I'm trying to understand why this simple script doesn't trigger a single run of the GC and eats all memory:
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:
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:
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!
        
           Updated by nobu (Nobuyoshi Nakada) about 11 years ago
          Updated by nobu (Nobuyoshi Nakada) about 11 years ago
          
          
        
        
      
      - 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:
require 'gdk3' loop do Gdk::Pixbuf.new('foo.png') end
Ruby doesn't know about memories malloced inside gdk library, so they can't trigger GC.
puts GC.stat[:count] if (i / 100).zero?
You might want to write (i % 100)?
        
           Updated by nobu (Nobuyoshi Nakada) about 11 years ago
          Updated by nobu (Nobuyoshi Nakada) about 11 years ago
          
          
        
        
      
      On 2014/09/16 11:35, Michel Boaventura wrote:
Ruby doesn't know about memories >
malloced inside gdk library, so they >can't trigger GC.But if ruby doesn't know about this allocations, how it can collect this memory if asked manually?
The object itself knows how to release the resources it acquired.