Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix GH-9266: GC root buffer keeps growing when dtors are present
Do not reset cleared count on GC rerun. Closes GH-9265.
- Loading branch information
Showing
3 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--TEST-- | ||
GC 045: Total count persisted when GC is rerun due to destructor call | ||
--INI-- | ||
zend.enable_gc=1 | ||
--FILE-- | ||
<?php | ||
class GlobalData | ||
{ | ||
public static Bar $bar; | ||
} | ||
|
||
class Value | ||
{ | ||
public function __destruct() | ||
{ | ||
new Bar(); | ||
} | ||
} | ||
|
||
class Bar | ||
{ | ||
public function __construct() | ||
{ | ||
GlobalData::$bar = $this; | ||
} | ||
} | ||
|
||
class Foo | ||
{ | ||
public Foo $selfRef; | ||
public Value $val; | ||
|
||
public function __construct(Value $val) | ||
{ | ||
$this->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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters