Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
GC.count
() -> ::Integer
self.count → integer
gc.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/gc.rb, line 148
def self.count
Primitive.gc_count
end
Returns the total number of times garbage collection has occurred:
With the default GC, counts the current Ractor’s collections.
Example
GC.count # => 385 GC.start GC.count # => 386
Ruby version changes
-
4.1
-
GC.statacceptsscope: :ractor(the default),scope: :local(a synonym for:ractor), andscope: :global. With the default collector, the global scope reports cumulative collection counts and measured marking/sweeping CPU time across Ractors, including history from destroyed object spaces, without requesting a stop-the-world snapshot. UnscopedGC.stat,GC.count, andGC.total_timeretain their current-Ractor behavior.
-