Module: GC

Defined in:
gc.c

Defined Under Namespace

Modules: Profiler

Constant Summary collapse

INTERNAL_CONSTANTS =

internal constants

gc_constants
OPTS =

GC build options

opts = rb_ary_new()

Class Method Summary collapse

Class Method Details

.add_stress_to_classObject

Raises NoMemoryError when allocating an instance of the given classes.



11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
# File 'gc.c', line 11769

static VALUE
rb_gcdebug_add_stress_to_class(int argc, VALUE *argv, VALUE self)
{
    rb_objspace_t *objspace = &rb_objspace;

    if (!stress_to_class) {
	stress_to_class = rb_ary_tmp_new(argc);
    }
    rb_ary_cat(stress_to_class, argv, argc);
    return self;
}

.malloc_allocated_sizeInteger

Returns the size of memory allocated by malloc().

Only available if ruby was built with CALC_EXACT_MALLOC_SIZE.

Returns:



10308
10309
10310
10311
10312
# File 'gc.c', line 10308

static VALUE
gc_malloc_allocated_size(VALUE self)
{
    return UINT2NUM(rb_objspace.malloc_params.allocated_size);
}

.malloc_allocationsInteger

Returns the number of malloc() allocations.

Only available if ruby was built with CALC_EXACT_MALLOC_SIZE.

Returns:



10323
10324
10325
10326
10327
# File 'gc.c', line 10323

static VALUE
gc_malloc_allocations(VALUE self)
{
    return UINT2NUM(rb_objspace.malloc_params.allocations);
}

.remove_stress_to_classObject

No longer raises NoMemoryError when allocating an instance of the given classes.



11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
# File 'gc.c', line 11789

static VALUE
rb_gcdebug_remove_stress_to_class(int argc, VALUE *argv, VALUE self)
{
    rb_objspace_t *objspace = &rb_objspace;
    int i;

    if (stress_to_class) {
	for (i = 0; i < argc; ++i) {
	    rb_ary_delete_same(stress_to_class, argv[i]);
	}
	if (RARRAY_LEN(stress_to_class) == 0) {
	    stress_to_class = 0;
	}
    }
    return Qnil;
}

.verify_compaction_referencesnil

Verify compaction reference consistency.

This method is implementation specific. During compaction, objects that were moved are replaced with T_MOVED objects. No object should have a reference to a T_MOVED object after compaction.

This function doubles the heap to ensure room to move all objects, compacts the heap to make sure everything moves, updates all references, then performs a full GC. If any object contains a reference to a T_MOVED object, that object should be pushed on the mark stack, and will make a SEGV.

Returns:

  • (nil)


8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
# File 'gc.c', line 8666

static VALUE
gc_verify_compaction_references(int argc, VALUE *argv, VALUE mod)
{
    rb_objspace_t *objspace = &rb_objspace;
    int use_toward_empty = FALSE;
    int use_double_pages = FALSE;

    if (dont_gc) return Qnil;

    VALUE opt = Qnil;
    static ID keyword_ids[2];
    VALUE kwvals[2];

    kwvals[1] = Qtrue;

    rb_scan_args(argc, argv, "0:", &opt);

    if (!NIL_P(opt)) {
        if (!keyword_ids[0]) {
            keyword_ids[0] = rb_intern("toward");
            keyword_ids[1] = rb_intern("double_heap");
        }

        rb_get_kwargs(opt, keyword_ids, 0, 2, kwvals);
        if (rb_intern("empty") == rb_sym2id(kwvals[0])) {
            use_toward_empty = TRUE;
        }
        if (kwvals[1] != Qundef && RTEST(kwvals[1])) {
            use_double_pages = TRUE;
        }
    }

    gc_compact(objspace, use_toward_empty, use_double_pages, TRUE);
    return gc_compact_stats(objspace);
}

.verify_internal_consistencynil

Verify internal consistency.

This method is implementation specific. Now this method checks generational consistency if RGenGC is supported.

Returns:

  • (nil)


6152
6153
6154
6155
6156
6157
6158
# File 'gc.c', line 6152

static VALUE
gc_verify_internal_consistency_m(VALUE dummy)
{
    gc_verify_internal_consistency(&rb_objspace);

    return Qnil;
}

.verify_transient_heap_internal_consistencyObject



6238
6239
6240
6241
6242
6243
# File 'gc.c', line 6238

static VALUE
gc_verify_transient_heap_internal_consistency(VALUE dmy)
{
    rb_transient_heap_verify();
    return Qnil;
}