Skip to content

Commit 8337645

Browse files
authored
Merge pull request rails#43686 from eregon/improve-total_allocated_objects-check
Improve check for GC.stat(:total_allocated_objects)
2 parents 06beead + 302b966 commit 8337645

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

activesupport/lib/active_support/notifications/instrumenter.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,14 @@ def now_cpu # rubocop:disable Lint/DuplicateMethods
158158
end
159159
end
160160

161-
begin
162-
GC.stat(:total_allocated_objects)
163-
rescue ArgumentError # Likely on JRuby
161+
if GC.stat.key?(:total_allocated_objects)
164162
def now_allocations
165-
0
166-
end
167-
else
168-
def now_allocations # rubocop:disable Lint/DuplicateMethods
169163
GC.stat(:total_allocated_objects)
170164
end
165+
else # Likely on JRuby, TruffleRuby
166+
def now_allocations
167+
0
168+
end
171169
end
172170
end
173171
end

0 commit comments

Comments
 (0)