-
-
Save e-jambon/21cb3e558082c130b47a6089056610d0 to your computer and use it in GitHub Desktop.
Revisions
-
iboard revised this gist
May 25, 2013 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ def self.finalize(bar) end f=Foo.new puts "Foo.bar is #{f.bar} now" f=nil @@ -22,4 +22,4 @@ def self.finalize(bar) GC.start sleep 1 # make sure you will see the message # before ruby quits puts "done" -
iboard revised this gist
May 25, 2013 . 1 changed file with 8 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,12 +11,15 @@ def self.finalize(bar) end . f=Foo.new puts "Foo.bar is #{f.bar} now" f=nil # Force ruby to start the Garbage Collector # In a real program you don't have to do this # ruby will run the GC automatically. GC.start sleep 1 # make sure you will see the message # before ruby quits puts "done" -
iboard created this gist
May 25, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ class Foo attr_reader :bar def initialize @bar = 123 ObjectSpace.define_finalizer( self, self.class.finalize(bar) ) end def self.finalize(bar) proc { puts "DESTROY OBJECT #{bar}" } end end f=Foo.new puts "Do something" puts "f destroyed" puts "starting GC" f=nil GC.start sleep 1 puts "done"