Mega Code Archive

 
Categories / Ruby / Development
 

Call GC to do a garbage collection

a = "hello" puts "'hello's object id is #{a.id}" ObjectSpace.define_finalizer(a) { |id| puts "Destroying #{id}" } GC.start a = nil puts "The original string is now a candidate for collection" GC.start