On Sat, Apr 01, 2006 at 06:31:42AM +0900, Justin Collins wrote:
> I believe this is the case if the garbage collector never runs. That is, 
> if the program exits before it is necessary.
> Also, there are situations in which objects are never released, so the 
> finalize method won't be called then, either. If I recall correctly.

The finalizers will be run on exit

    ObjectSpace.define_finalizer(a = "", lambda{ puts "EXECUTED" })
    END{ puts "leaving" }
    puts "hi"
    RUBY_VERSION                                       # => "1.8.4"
    # >> hi
    # >> leaving
    # >> EXECUTED

But you can bypass them with Kernel#exit!

    batsman@tux-chan:~/mess/current$ cat exit_bang.rb 
    ObjectSpace.define_finalizer(a = "", lambda{ puts "EXECUTED" })
    END{ puts "leaving" }
    puts "hi"
    puts RUBY_VERSION
    exit!
    batsman@tux-chan:~/mess/current$ ruby exit_bang.rb 
    hi
    1.8.4

-- 
Mauricio Fernandez  -   http://eigenclass.org   -  singular Ruby