From: Clifford Heath Date: 2012-06-27T17:16:53+09:00 Subject: [ruby-core:45910] Re: [ruby-trunk - Bug #6614] GC doesn't collect objects bound to (collectable) proc On 27/06/2012, at 4:35 PM, nobu (Nobuyoshi Nakada) wrote: > headius (Charles Nutter) wrote: >> Finalizers in JRuby are stored on a reference from the object itself, so they don't actually prevent the object from collecting. > > You're missing the point. Is he? Surely somewhere in that loop{finalized_puts []} the GC will activate, and that will find collectable objects (with finalisers attached in JRuby). In MRI, they might be found but they won't be finalised, if I understand the behaviour right. Clifford Heath. > ---------------------------------------- > Bug #6614: GC doesn't collect objects bound to (collectable) proc > https://bugs.ruby-lang.org/issues/6614#change-27513 > > Author: rogerdpack (Roger Pack) > Status: Rejected > Priority: Normal > Assignee: > Category: > Target version: > ruby -v: tcs-ruby 1.9.3p28 (2012-01-28, TCS patched 2012-01-30) [i386-mingw32] > > > Hello all. > Previously discussed here: http://www.ruby-forum.com/topic/4402823 > > I would expect the following code to eventually run the finalizers mentioned: > > def finalized_puts bad > ObjectSpace.define_finalizer(bad) { print 'collector run', bad } > end > > loop { finalized_puts [] } > > This works in jruby as expected, but not in MRI. This has the unfortunate side effect of making define_finalizer *very* difficult to actually use right http://www.mikeperham.com/2010/02/24/the-trouble-with-ruby-finalizers/ > > Cheers! > > > > -- > http://bugs.ruby-lang.org/ >