examples/memory.rb in jmx4r-0.0.2 vs examples/memory.rb in jmx4r-0.0.3
- old
+ new
@@ -1,21 +1,21 @@
#!/usr/bin/env jruby
-
+require 'rubygems'
require 'jmx4r'
def display header, memory_usage
- puts header
- memory_usage.composite_type.key_set.each do |type|
- puts "\t#{type} : #{memory_usage.get type}"
- end
+ puts header
+ memory_usage.composite_type.key_set.each do |type|
+ puts "\t#{type} : #{memory_usage.get type}"
+ end
end
memory = JMX::MBean.find_by_name "java.lang:type=Memory"
display "Heap Memory Usage", memory.heap_memory_usage
display "Non Heap Memory Usage", memory.heap_memory_usage
if ARGV.length == 1 and ARGV[0] == "gc"
- puts "trigger a garbage collection"
- memory.gc
- display "Heap Memory Usage", memory.heap_memory_usage
- display "Non Heap Memory Usage", memory.heap_memory_usage
+ puts "trigger a garbage collection"
+ memory.gc
+ display "Heap Memory Usage", memory.heap_memory_usage
+ display "Non Heap Memory Usage", memory.heap_memory_usage
end
\ No newline at end of file