Thomas Enebo has been a practitioner of Java for over a decade and he is the co-lead of the JRuby project. Thomas has also been happily using Ruby since 2001. In addition to working on JRuby, Tom is interested in improving the state of alternative languages on the Java Virtual Machine. Thomas is a DZone MVB and is not an employee of DZone and has posted 3 posts at DZone. You can read more from them at their website. View Full User Profile

Thomas Enebo Releases JMX Gem

  • submit to reddit
I wrote a JMX client library quite a while back and I finally got around to putting it on jruby-extras. To get the magic you can:
jruby -S gem install jmx

Once you have it you can do things like:
require 'jmx'

server = JMX.simple_server
client = JMX.connect
memory = client["java.lang:type=Memory"]

puts memory.heap_memory_usage.used
puts memory.heap_memory_usage.used


Or even construct your own MBean from within Ruby code:

class MyDynamicMBean < RubyDynamicMBean
operation "Doubles a value"
parameter :int, "a", "Value to double"
returns :int
def double(a)
a + a
[see jmx/test/jmx_server_test.rb for details on how to register]

This library is still a little rough around the edges, but I have used it to great utility for debugging permgen memory issues. Charlie also recently just committed some MBeans for monitoring the JIT statistics (along with a way to flush the JIT cache). This client should be helpful for us to write some nice Ruby-friendly scripts to analyze a running instance.

Have fun and if you have questions come onto our IRC channel (#jruby at or send an email to one of our mailing lists.
Published at DZone with permission of Thomas Enebo, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)