|
|
1.1 misho 1: --TEST--
2: GC 029: GC and destructors
3: --INI--
4: zend.enable_gc=1
5: --FILE--
6: <?php
7: class Foo {
8: public $bar;
9: public $x = array(1,2,3);
10: function __destruct() {
11: if ($this->bar !== null) {
12: $this->x = null;
13: unset($this->bar);
14: }
15: }
16: }
17: class Bar {
18: public $foo;
19: function __destruct() {
20: if ($this->foo !== null) {
21: unset($this->foo);
22: }
23: }
24:
25: }
26: $foo = new Foo();
27: $bar = new Bar();
28: $foo->bar = $bar;
29: $bar->foo = $foo;
30: unset($foo);
31: unset($bar);
32: var_dump(gc_collect_cycles());
33: ?>
34: --EXPECT--
35: int(2)