Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 64bf82244fa6
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c9b8aa1d5c59
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Nov 6, 2014

  1. Copy the full SHA
    f3016cb View commit details
  2. Merge pull request #2118 from cheald/fix_gc_stat

    Fix GC.stat for 2.2 compatibility
    enebo committed Nov 6, 2014
    Copy the full SHA
    c9b8aa1 View commit details
Showing with 13 additions and 2 deletions.
  1. +12 −2 core/src/main/ruby/jruby/kernel/gc.rb
  2. +1 −0 test/mri/excludes/TestGc.rb
14 changes: 12 additions & 2 deletions core/src/main/ruby/jruby/kernel/gc.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
module GC
def self.stat(all_stats = {})
def self.stat(all_stats_or_key = {})
gc_beans = java.lang.management.ManagementFactory.garbage_collector_mx_beans
pool_beans = {}
java.lang.management.ManagementFactory.memory_pool_mx_beans.each do |pool_bean|
pool_beans[pool_bean.name] = pool_bean
end

all_stats = all_stats_or_key.is_a?(Hash) ? all_stats_or_key : {}

all_stats.merge!({
:count => 0,
:time => 0,
@@ -53,7 +55,15 @@ def self.stat(all_stats = {})
end
end

all_stats
if all_stats_or_key.is_a?(Symbol)
if all_stats.key?(all_stats_or_key)
all_stats[all_stats_or_key]
else
raise ArgumentError.new(format("Unknown key %s", all_stats_or_key).force_encoding("UTF-8"))
end
else
all_stats
end
end

begin
1 change: 1 addition & 0 deletions test/mri/excludes/TestGc.rb
Original file line number Diff line number Diff line change
@@ -16,3 +16,4 @@
exclude :test_stat, "tests count_objects"
exclude :test_sweep_in_finalizer, ""
exclude :test_verify_internal_consistency, ""
exclude :test_stat_constraints, ""