module GC::Profiler
The GC profiler provides access to information on GC runs including time, length and object space size.
Example:
GC::Profiler.enable require 'rdoc/rdoc' GC::Profiler.report GC::Profiler.disable
See also GC.count, GC.malloc_allocated_size and GC.malloc_allocations
Public Class Methods
() → nil
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/gc.rbs, line 33
def self.clear: () -> nil
Clears the GC profiler data.
() → nil
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/gc.rbs, line 41
def self.disable: () -> nil
Stops the GC profiler.
() → nil
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/gc.rbs, line 49
def self.enable: () -> nil
Starts the GC profiler.
() → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/gc.rbs, line 57
def self.enabled?: () -> bool
The current status of GC profile mode.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/gc.rbs, line 114
def self.raw_data: () -> Array[Hash[Symbol, untyped]]?
Returns an Array of individual raw profile data Hashes ordered from earliest to latest by :GC_INVOKE_TIME.
For example:
[
{
:GC_TIME=>1.3000000000000858e-05,
:GC_INVOKE_TIME=>0.010634999999999999,
:HEAP_USE_SIZE=>289640,
:HEAP_TOTAL_SIZE=>588960,
:HEAP_TOTAL_OBJECTS=>14724,
:GC_IS_MARKED=>false
},
# ...
]
The keys mean:
:GC_TIME:GC_INVOKE_TIME-
Timeelapsed in seconds from startup to when theGCwas invoked :HEAP_USE_SIZE-
Total bytes of heap used
:HEAP_TOTAL_SIZE-
Total size of heap in bytes
:HEAP_TOTAL_OBJECTS-
Total number of objects
:GC_IS_MARKED-
Returns
trueif theGCis in mark phase
If ruby was built with GC_PROFILE_MORE_DETAIL, you will also have access to the following hash keys:
:GC_MARK_TIME :GC_SWEEP_TIME :ALLOCATE_INCREASE :ALLOCATE_LIMIT :HEAP_USE_PAGES :HEAP_LIVE_OBJECTS :HEAP_FREE_OBJECTS :HAVE_FINALIZE :
(?_Reporter io) → nil
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/gc.rbs, line 123
def self.report: (?_Reporter io) -> nil
Writes the GC::Profiler.result to $stdout or the given IO object.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/gc.rbs, line 139
def self.result: () -> String
Returns a profile data report such as:
GC 1 invokes.
Index Invoke Time(sec) Use Size(byte) Total Size(byte) Total Object GC time(ms)
1 0.012 159240 212940 10647 0.00000000000001530000
() → Float
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/gc.rbs, line 147
def self.total_time: () -> Float
The total time used for garbage collection in seconds