Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

class method

GC::Profiler.configure

GC::Profiler.configure(max_records: 4096) → nil

Configures how many raw profile records are retained by GC::Profiler.raw_data.

The profiler keeps at most max_records records in a bounded ring buffer. When the buffer is full, newer GC records overwrite the oldest retained records. The default limit is 4096 records.

Pass nil to restore the historical unbounded behavior:

Example
GC::Profiler.configure(max_records: nil)

Changing max_records clears existing raw profile data. This method does not enable or disable the profiler; use GC::Profiler.enable and GC::Profiler.disable for that.