mirror of
https://github.com/ruby/ruby.git
synced 2026-08-01 17:57:19 +08:00
Fix GC.stress for object allocation
GC stress was broken for object allocation.
This commit is contained in:
parent
2641d40c38
commit
62f325a955
Notes:
git
2026-07-23 13:32:37 +00:00
@ -2759,6 +2759,12 @@ newobj_bump_pointer_miss(rb_objspace_t *objspace, rb_ractor_newobj_cache_t *gc_c
|
||||
static VALUE
|
||||
newobj_alloc(rb_objspace_t *objspace, rb_ractor_newobj_cache_t *gc_cache, size_t heap_idx, bool vm_locked)
|
||||
{
|
||||
if (RB_UNLIKELY(ruby_gc_stressful)) {
|
||||
if (!garbage_collect(objspace, GPR_FLAG_NEWOBJ)) {
|
||||
rb_memerror();
|
||||
}
|
||||
}
|
||||
|
||||
VALUE obj = ractor_cache_allocate_slot(objspace, gc_cache, heap_idx);
|
||||
|
||||
if (RB_UNLIKELY(obj == Qfalse)) {
|
||||
|
||||
@ -851,6 +851,17 @@ class TestGc < Test::Unit::TestCase
|
||||
assert_nil(GC.verify_internal_consistency)
|
||||
end
|
||||
|
||||
def test_gc_stress_on_obj_allocation
|
||||
EnvUtil.under_gc_stress do
|
||||
count = GC.count
|
||||
iters = 100
|
||||
iters.times do
|
||||
Object.new
|
||||
end
|
||||
assert_operator(GC.count - count, :>=, iters)
|
||||
end
|
||||
end
|
||||
|
||||
def test_gc_stress_on_realloc
|
||||
assert_normal_exit(<<-'end;', '[Bug #9859]')
|
||||
class C
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user