Skip to content

Instantly share code, notes, and snippets.

@i0rek
Last active Dec 11, 2015
Embed
What would you like to do?
$ ruby --version
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.0.0]
$ irb --version
irb 0.9.6(09/06/30)
$ irb
> a = "gc me"
=> "gc me"
> ObjectSpace.define_finalizer(a, proc {|id| puts "Finalizer one on #{id}" })
=> [0, #<Proc:0x007f9e2abb9200@(irb):3>]
> a = nil
> GC.start
=> nil
> ObjectSpace.garbage_collect
=> nil
> exit
Finalizer one on 70158648666720
@i0rek

This comment has been minimized.

Copy link
Owner Author

@i0rek i0rek commented Jan 15, 2013

What's going on?

I expect that either GC.start or ObjectSpace.garbage_collect is calling the finalizer - but thats happening only when I close the session.

WHY?

@coffeejunk

This comment has been minimized.

Copy link

@coffeejunk coffeejunk commented Jan 15, 2013

$ ruby --version
ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-darwin12.2.1]
$ irb --version 
irb 0.9.6(09/06/30)
$ irb 
> a = "gc me"
 => "gc me" 
> ObjectSpace.define_finalizer(a, proc {|id| puts "Finalizer one on #{id}" })
 => [0, #<Proc:0x007fcfa188e410@(irb):2>] 
> a = nil
 => nil 
> GC.start
Finalizer one on 70264872626760
 => nil 
> ObjectSpace.garbage_collect
 => nil 
> ^D
@i0rek

This comment has been minimized.

Copy link
Owner Author

@i0rek i0rek commented Jan 15, 2013

@coffeejunk Thanks! I'm going to upgrade then!

@i0rek

This comment has been minimized.

Copy link
Owner Author

@i0rek i0rek commented Jan 15, 2013

@coffeejunk It works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment