Skip to content

Commit

Permalink
Add key force_major_gc_count to GC.stat_heap
Browse files Browse the repository at this point in the history
force_major_gc_count is the number of times the size pool forced major
GC to run.
  • Loading branch information
peterzhu2118 committed Jun 8, 2022
1 parent a07acbe commit fafe681
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gc.c
Expand Up @@ -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
};

Expand All @@ -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
}
}
Expand Down Expand Up @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions test/ruby/test_gc.rb
Expand Up @@ -160,6 +160,7 @@ def test_stat_heap
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)
Expand Down

0 comments on commit fafe681

Please sign in to comment.