mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fix GH-13569: GC buffer unnecessarily grows up to GC_MAX_BUF_SIZE when scanning WeakMaps
This commit is contained in:
22
Zend/tests/gh13569.phpt
Normal file
22
Zend/tests/gh13569.phpt
Normal file
@@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
GH-13569: GC buffer grows up to GC_MAX_BUF_SIZE when scanning WeakMaps
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$wm = new WeakMap();
|
||||
$objs = [];
|
||||
for ($i = 0; $i < 30_000; $i++) {
|
||||
$objs[] = $obj = new stdClass;
|
||||
$wm[$obj] = $obj;
|
||||
}
|
||||
|
||||
gc_collect_cycles();
|
||||
|
||||
$tmp = $wm;
|
||||
$tmp = null;
|
||||
|
||||
gc_collect_cycles();
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
==DONE==
|
||||
@@ -718,7 +718,7 @@ static void ZEND_FASTCALL gc_extra_root(zend_refcounted *ref)
|
||||
|
||||
if (EXPECTED(GC_HAS_UNUSED())) {
|
||||
idx = GC_FETCH_UNUSED();
|
||||
} else if (EXPECTED(GC_HAS_NEXT_UNUSED_UNDER_THRESHOLD())) {
|
||||
} else if (EXPECTED(GC_HAS_NEXT_UNUSED())) {
|
||||
idx = GC_FETCH_NEXT_UNUSED();
|
||||
} else {
|
||||
gc_grow_root_buffer();
|
||||
|
||||
Reference in New Issue
Block a user