If I do this (in Ruby 1.6.5 and 1.7.1):

  def finalize
    puts "finalize"
  end

  def main
    ObjectSpace.define_finalizer(Array.new, Object.method(:finalize).to_proc)
  end

  main
  GC.start
  puts "leaving"

Then I get:

  leaving

The reason (which was not immediately obvious to me) was that finalizers
must take an argument.  Thus, if I rewrite finalize to look like:

  def finalize(obj)
    puts "finalize"
  end

then all is well:

  finalize
  leaving

Should the garbage collector print an error message when it cannot call a
finalizer?

Paul