Resource allocation/deallocation 1 # Method 1: Use finalizers (let the GC do the work) 2 class Foo 3 class Helper 4 def initialize 5 @x = allocate_some_resource 6 end 7 8 def finalize 9 free_some_resource(@x) 10 end 11 end