123456789_123456789_123456789_123456789_123456789_

Module: GC::Profiler

Relationships & Source Files
Defined in: gc.c

Overview

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 count, malloc_allocated_size and malloc_allocations

Class Attribute Summary

Class Method Summary

Class Attribute Details

.enabled?Boolean (readonly)

The current status of ::GC profile mode.

Class Method Details

.clearnil

Clears the ::GC profiler data.

.raw_dataArray, ...

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

Time elapsed in seconds for this GC run

:GC_INVOKE_TIME

Time elapsed in seconds from startup to when the GC was 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 true if the GC is 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

.report .report(io)

Writes the .result to $stdout or the given ::IO object.

.resultString

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

.total_timeFloat

The total time used for garbage collection in seconds