Skip to content
class method

GC.start

(?immediate_sweep: ::boolish, ?immediate_mark: ::boolish, ?full_mark: ::boolish) -> nil
start(full_mark: true, immediate_mark: true, immediate_sweep: true)

Initiates garbage collection, even if explicitly disabled by GC.disable.

Keyword arguments:

  • full_mark: its boolean value determines whether to perform a major garbage collection cycle:

    • true: initiates a major garbage collection cycle, meaning all objects (old and new) are marked.

    • false: initiates a minor garbage collection cycle, meaning only young objects are marked.

  • immediate_mark: its boolean value determines whether to perform incremental marking:

    • true: marking is completed before the method returns.

    • false: marking is performed by parts, interleaved with program execution both before the method returns and afterward; therefore marking may not be completed before the return. Note that if full_mark is false, marking will always be immediate, regardless of the value of immediate_mark.

  • immediate_sweep: its boolean value determines whether to defer sweeping (using lazy sweep):

    • true: sweeping is completed before the method returns.

    • false: sweeping is performed by parts, interleaved with program execution both before the method returns and afterward; therefore sweeping may not be completed before the return.

Note that these keyword arguments are implementation- and version-dependent, are not guaranteed to be future-compatible, and may be ignored in some implementations.