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
-
.add_stress_to_class ⇒ Object
Raises NoMemoryError when allocating an instance of the given classes.
-
.malloc_allocated_size ⇒ Integer
Returns the size of memory allocated by malloc().
-
.malloc_allocations ⇒ Integer
Returns the number of malloc() allocations.
-
.remove_stress_to_class ⇒ Object
No longer raises NoMemoryError when allocating an instance of the given classes.
-
.verify_compaction_references ⇒ nil
Verify compaction reference consistency.
-
.verify_internal_consistency ⇒ nil
Verify internal consistency.
- .verify_transient_heap_internal_consistency ⇒ Object
Class Method Details
.add_stress_to_class ⇒ Object
Raises NoMemoryError when allocating an instance of the given classes.
11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 |
# File 'gc.c', line 11738
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_size ⇒ Integer
Returns the size of memory allocated by malloc().
Only available if ruby was built with CALC_EXACT_MALLOC_SIZE
.
10277 10278 10279 10280 10281 |
# File 'gc.c', line 10277
static VALUE
gc_malloc_allocated_size(VALUE self)
{
return UINT2NUM(rb_objspace.malloc_params.allocated_size);
}
|
.malloc_allocations ⇒ Integer
Returns the number of malloc() allocations.
Only available if ruby was built with CALC_EXACT_MALLOC_SIZE
.
10292 10293 10294 10295 10296 |
# File 'gc.c', line 10292
static VALUE
gc_malloc_allocations(VALUE self)
{
return UINT2NUM(rb_objspace.malloc_params.allocations);
}
|
.remove_stress_to_class ⇒ Object
No longer raises NoMemoryError when allocating an instance of the given classes.
11758 11759 11760 11761 11762 11763 11764 11765 11766 11767 11768 11769 11770 11771 11772 11773 |
# File 'gc.c', line 11758
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_references ⇒ nil
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.
8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 |
# File 'gc.c', line 8635
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_consistency ⇒ nil
Verify internal consistency.
This method is implementation specific. Now this method checks generational consistency if RGenGC is supported.
6121 6122 6123 6124 6125 6126 6127 |
# File 'gc.c', line 6121
static VALUE
gc_verify_internal_consistency_m(VALUE dummy)
{
gc_verify_internal_consistency(&rb_objspace);
return Qnil;
}
|
.verify_transient_heap_internal_consistency ⇒ Object
6207 6208 6209 6210 6211 6212 |
# File 'gc.c', line 6207
static VALUE
gc_verify_transient_heap_internal_consistency(VALUE dmy)
{
rb_transient_heap_verify();
return Qnil;
}
|