class IdleGC::Timer

Defined in:

idle-gc/timer.cr

Constant Summary

DEFAULT_BYTES_SINCE_GC_THRESHOLD = 0_u64
DEFAULT_FORCE_GC_PERIOD = 2.minutes
DEFAULT_POLL_INTERVAL = 1.second

Class Method Summary

Class Method Detail

def self.bytes_since_gc_threshold=(v : UInt64) : Nil #

Set to the minimum number of allocated memory bytes required to trigger a collection.

Default is 0, meaning that any allocated memory will trigger a collection.


[View source]
def self.force_gc_period=(v : Time::Span | Nil) : Nil #

Set the force GC period, which forces a GC run when non-idle.

Set to nil to disable this behavior.

Defaults to 2 minutes.


[View source]
def self.poll_interval=(v : Time::Span) : Nil #

Set the polling interval.

Polling more frequently will keep memory usage lower, but will burn more CPU time on garbage collection.

The sweet spot is probably seconds to minutes.


[View source]
def self.start : Nil #

Start a background Fiber that runs garbage collection periodically.

(Also runs garbage collection immediately.)


[View source]
def self.stop : Nil #

Stop periodic garbage collection. Used for testing.

(You don't need to call this. Just let IdleGC die naturally when your program exits.)


[View source]