www.Linux-Support.com

  • Increase font size
  • Default font size
  • Decrease font size
Home

Ruby 1.9.3 with GC Improvements

Print

ruby-logo-160Ruby contains a number of improvements in Release 1.9.3. Beside bugfixes and new features the Garbage Collector has been optimized.

The new interface to the module GC contains a number of methods, that are of interest for programmers, that are required to optimize long-running processes and to work with huge data amounts.

In Release 1.9.3 of Ruby the module GC has been extended with a method returning some statistics related to the garbage collector. The method is called 'GC.stat'. The following example contains an example how to use the new method.

1
2
3
4
5
6
7
8
# load modules
require 'pp'
 
# print outputs to stdout
print "number of times the GC has been run: #{GC.count}\n"
print "some statistics:\n"
pp GC.stat
 

When running the script you may get outputs like this:

number of time the GC has been run: 2
some statistics:
{:count=>2,
 :heap_used=>43,
 :heap_length=>43,
 :heap_increment=>0,
 :heap_live_num=>7920,
 :heap_free_num=>9586,
 :heap_final_num=>72}
 

For details regarding the returned dataset, please refer to the online documention of the module GC.

Related resources:

Last Updated on Monday, 09 January 2012 16:58