Garbage Collection

 
   

Ruby Way
By Hal Fulton
Slots : 1.0
Table of Contents
 


The garbage collector does not require reference counts. Ruby currently uses conservative "mark and sweep" for automatic garbage collection (GC), and will soon be using generational GC. There is no need to keep track of reference counts in your C extensions. Simply provide functions for the GC to use for marking objects and freeing memory.

One consequence to this approach is that you also have less control over the destruction of an object. Of course, you can use GC.start to force cleanup early, and you can also temporarily disable it to prevent code blocks from being interrupted. You can use finalizers to run a procedure after the object is destroyed, but this is not really a destructor.


   

 

 



The Ruby Way
The Ruby Way, Second Edition: Solutions and Techniques in Ruby Programming (2nd Edition)
ISBN: 0672328844
EAN: 2147483647
Year: 2000
Pages: 119
Authors: Hal Fulton

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net