Module: GC
- Defined in:
- lib/jruby/gc_stats.rb
Constant Summary collapse
- GC_MBEANS =
ManagementFactory.garbage_collector_mxbeans
- POOL_MBEANS =
ManagementFactory.memory_pool_mxbeans
Class Method Summary collapse
-
.allocation_size ⇒ Object
A delta in the committed (active main memory) size of all memory pools.
-
.collections ⇒ Object
Number of GC runs since stat collection started.
- .disable_stats ⇒ Object
-
.dump ⇒ Object
Dumping the basic data for each pool.
-
.enable_stats ⇒ Object
no perf penalty for stats on JVM, but save current counts.
-
.growth ⇒ Object
Number of heap bytes requested since the last GC run.
- .num_allocations ⇒ Object
-
.time ⇒ Object
Amount of time spent in GC since stat collection started This is accumulated across all GCs in the system.
Class Method Details
.allocation_size ⇒ Object
A delta in the committed (active main memory) size of all memory pools
62 63 64 65 |
# File 'lib/jruby/gc_stats.rb', line 62 def self.allocation_size new_size = _total_pool_size new_size - @start_size end |
.collections ⇒ Object
Number of GC runs since stat collection started. This is accumulated across all GCs in the system.
23 24 25 26 27 |
# File 'lib/jruby/gc_stats.rb', line 23 def self.collections raise "GC stats are not enabled" unless @enabled new_count = _collection_count new_count - @start_count end |
.disable_stats ⇒ Object
17 18 19 |
# File 'lib/jruby/gc_stats.rb', line 17 def self.disable_stats @enabled = false end |
.dump ⇒ Object
Dumping the basic data for each pool
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/jruby/gc_stats.rb', line 44 def self.dump filename = ENV['RUBY_GC_DATA_FILE'] begin file = filename ? File.open(filename, 'w') : $stderr for pool_bean in POOL_MBEANS file.puts "Name: #{pool_bean.name}" file.puts " Type: #{pool_bean.type}" file.puts " Peak usage: #{pool_bean.peak_usage}" file.puts " Current usage: #{pool_bean.usage}" file.puts " Usage after last collection: #{pool_bean.collection_usage}" file.puts " Managers: #{pool_bean.memory_manager_names.to_a.join(', ')}" end ensure file.close if filename end end |
.enable_stats ⇒ Object
no perf penalty for stats on JVM, but save current counts
11 12 13 14 15 16 |
# File 'lib/jruby/gc_stats.rb', line 11 def self.enable_stats @enabled = true @start_count = _collection_count @start_time = _collection_time @start_size = _total_pool_size end |
.growth ⇒ Object
Number of heap bytes requested since the last GC run. This includes all memory pools.
39 40 41 |
# File 'lib/jruby/gc_stats.rb', line 39 def self.growth _usage_versus_collected end |
.num_allocations ⇒ Object
67 68 69 |
# File 'lib/jruby/gc_stats.rb', line 67 def self.num_allocations # not sure this can be tracked on JVM; allocations happen all over end |
.time ⇒ Object
Amount of time spent in GC since stat collection started This is accumulated across all GCs in the system.
31 32 33 34 35 |
# File 'lib/jruby/gc_stats.rb', line 31 def self.time raise "GC stats are not enabled" unless @enabled new_time = _collection_time new_time - @start_time end |