[ANN] jruby_gc_stats 0.1: a set of GC monitoring methods similar toREE

  • Thread starter Charles Oliver Nutter
  • Start date
C

Charles Oliver Nutter

Hiya! I just released a gem called jruby_gc_stats, which provides for
JRuby most of the GC-monitoring methods users of Ruby Enterprise
Edition might be using. These methods are provided without any
performance impact using standard JVM monitoring capabilities, and
should work on any mainstream JVM.

Repo:

http://github.com/headius/jruby_gc_stats

Supported methods:

GC.enable_status/disable_stats
(stats do not incur any perf penalty on JRuby, so these methods just
reset counters)

GC.collections: number of garbage collections since "enable_stats"
GC.time: amount of time in GC since "enable_stats"
GC.growth: uncollected memory increase since last GC run
GC.dump: dump information about all memory pools
GC.allocation_size: increase in total heap size since "enable_stats"
caller_for_all_threads: dump the caller stack for all active threads

Unsupported:

GC.num_allocations: no equivalent on JVM
ObjectSpace.live_objects: requires doing a very costly heap dump
ObjectSpace.allocated_objects: requires starting JVM in debug mode

Install:

gem install jruby_gc_stats

Example:

require 'rubygems'
require 'jruby/gc_stats'

require 'pp'
puts "Enabling stats..."
GC.enable_stats
puts "allocation size: #{GC.allocation_size}"
puts "Running loop..."
1_000.times {
ary = []
1_000.times {ary << 'foo' + 'bar'}
}
puts "collections: #{GC.collections}"
puts "time: #{GC.time}ms"
puts "bytes since last GC: #{GC.growth}"
puts "size change: #{GC.allocation_size}"
puts "Dumping..."
GC.dump

puts "Dumping caller for all threads..."
2.times {Thread.new {sleep}}
pp caller_for_all_threads
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top