1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Add key force_major_gc_count to GC.stat_heap

force_major_gc_count is the number of times the size pool forced major
GC to run.
This commit is contained in:
Peter Zhu 2022-06-08 10:03:00 -04:00
parent a07acbe417
commit fafe68185c
2 changed files with 4 additions and 0 deletions

3
gc.c
View file

@ -11005,6 +11005,7 @@ enum gc_stat_heap_sym {
gc_stat_heap_sym_heap_tomb_slots,
gc_stat_heap_sym_total_allocated_pages,
gc_stat_heap_sym_total_freed_pages,
gc_stat_heap_sym_force_major_gc_count,
gc_stat_heap_sym_last
};
@ -11023,6 +11024,7 @@ setup_gc_stat_heap_symbols(void)
S(heap_tomb_slots);
S(total_allocated_pages);
S(total_freed_pages);
S(force_major_gc_count);
#undef S
}
}
@ -11065,6 +11067,7 @@ gc_stat_heap_internal(int size_pool_idx, VALUE hash_or_sym)
SET(heap_tomb_slots, SIZE_POOL_TOMB_HEAP(size_pool)->total_slots);
SET(total_allocated_pages, size_pool->total_allocated_pages);
SET(total_freed_pages, size_pool->total_freed_pages);
SET(force_major_gc_count, size_pool->force_major_gc_count);
#undef SET
if (!NIL_P(key)) { /* matched key should return above */

View file

@ -160,6 +160,7 @@ class TestGc < Test::Unit::TestCase
assert_operator stat_heap[:heap_tomb_slots], :>=, 0
assert_operator stat_heap[:total_allocated_pages], :>=, 0
assert_operator stat_heap[:total_freed_pages], :>=, 0
assert_operator stat_heap[:force_major_gc_count], :>=, 0
end
GC.stat_heap(0, stat_heap)