mirror of
https://github.com/php/php-src.git
synced 2024-12-02 22:34:55 +08:00
60a7e60b61
For objects with destructors, we will now only call the destructor in the initial GC run, and remove any nested data. The object is marked purple so it will be considered a root for the next GC run, at which point it will be fully destroyed, if possible. GC counts change on a number of tests, as the objects now get destroyed later.
27 lines
372 B
PHP
27 lines
372 B
PHP
--TEST--
|
|
GC 035: Lost inner-cycles garbage
|
|
--INI--
|
|
zend.enable_gc = 1
|
|
--FILE--
|
|
<?php
|
|
class A {
|
|
public $a;
|
|
public $x;
|
|
function __destruct() {
|
|
unset($this->x);
|
|
}
|
|
}
|
|
$a = new A;
|
|
$a->a = $a;
|
|
$a->x = [];
|
|
$a->x[] =& $a->x;
|
|
$a->x[] = $a;
|
|
var_dump(gc_collect_cycles());
|
|
unset($a);
|
|
var_dump(gc_collect_cycles());
|
|
var_dump(gc_collect_cycles());
|
|
--EXPECT--
|
|
int(0)
|
|
int(0)
|
|
int(2)
|