Module: GC

Defined in:
gc.c

Overview

The GC module provides an interface to Ruby’s mark and sweep garbage collection mechanism. Some of the underlying methods are also available via the ObjectSpace module.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.disableBoolean

Disables garbage collection, returning true if garbage collection was already disabled.

GC.disable   #=> false
GC.disable   #=> true

Returns:

  • (Boolean)


203
204
205
206
207
208
209
210
# File 'gc.c', line 203

VALUE
rb_gc_disable()
{
    int old = dont_gc;

    dont_gc = Qtrue;
    return old;
}

.enableBoolean

Enables garbage collection, returning true if garbage collection was previously disabled.

GC.disable   #=> false
GC.enable    #=> true
GC.enable    #=> false

Returns:

  • (Boolean)


182
183
184
185
186
187
188
189
# File 'gc.c', line 182

VALUE
rb_gc_enable()
{
    int old = dont_gc;

    dont_gc = Qfalse;
    return old;
}

.startnil .garbage_collectnil .garbage_collectnil

Initiates garbage collection, unless manually disabled.

Overloads:

  • .startnil

    Returns:

    • (nil)
  • .garbage_collectnil

    Returns:

    • (nil)
  • .garbage_collectnil

    Returns:

    • (nil)


1418
1419
1420
1421
1422
1423
# File 'gc.c', line 1418

VALUE
rb_gc_start()
{
    rb_gc();
    return Qnil;
}

Instance Method Details

#startnil #garbage_collectnil #garbage_collectnil

Initiates garbage collection, unless manually disabled.

Overloads:

  • #startnil

    Returns:

    • (nil)
  • #garbage_collectnil

    Returns:

    • (nil)
  • #garbage_collectnil

    Returns:

    • (nil)


1418
1419
1420
1421
1422
1423
# File 'gc.c', line 1418

VALUE
rb_gc_start()
{
    rb_gc();
    return Qnil;
}