diff --git a/Zend/tests/gc_045.phpt b/Zend/tests/gc_045.phpt new file mode 100644 index 0000000000000..865462ecfbc3f --- /dev/null +++ b/Zend/tests/gc_045.phpt @@ -0,0 +1,58 @@ +--TEST-- +GC 045: Total count persisted when GC is rerun due to destructor call +--INI-- +zend.enable_gc=1 +--FILE-- +val = $val; + $this->selfRef = $this; + } +} + +for ($j = 0; $j < 10; $j++) { + for ($i = 0; $i < 3000; $i++) { + new Foo(new Value()); + } +} + +var_dump(gc_status()); +?> +--EXPECT-- +array(4) { + ["runs"]=> + int(10) + ["collected"]=> + int(25000) + ["threshold"]=> + int(10001) + ["roots"]=> + int(10000) +} diff --git a/Zend/zend_gc.c b/Zend/zend_gc.c index 3319b7aa34e64..766e1ffea9a61 100644 --- a/Zend/zend_gc.c +++ b/Zend/zend_gc.c @@ -1469,12 +1469,13 @@ static void zend_gc_root_tmpvars(void); ZEND_API int zend_gc_collect_cycles(void) { - int count = 0; + int total_count = 0; bool should_rerun_gc = 0; bool did_rerun_gc = 0; rerun_gc: if (GC_G(num_roots)) { + int count; gc_root_buffer *current, *last; zend_refcounted *p; uint32_t gc_flags = 0; @@ -1652,6 +1653,7 @@ ZEND_API int zend_gc_collect_cycles(void) GC_TRACE("Collection finished"); GC_G(collected) += count; + total_count += count; GC_G(gc_active) = 0; } @@ -1668,7 +1670,7 @@ ZEND_API int zend_gc_collect_cycles(void) finish: zend_get_gc_buffer_release(); zend_gc_root_tmpvars(); - return count; + return total_count; } ZEND_API void zend_gc_get_status(zend_gc_status *status)