xref: /php-src/Zend/tests/gc_045.phpt (revision d0731934)
1--TEST--
2GC 045: Total count persisted when GC is rerun due to destructor call
3--INI--
4zend.enable_gc=1
5--FILE--
6<?php
7class GlobalData
8{
9    public static Bar $bar;
10}
11
12class Value
13{
14    public function __destruct()
15    {
16        new Bar();
17    }
18}
19
20class Bar
21{
22    public function __construct()
23    {
24        GlobalData::$bar = $this;
25    }
26}
27
28class Foo
29{
30    public Foo $selfRef;
31    public Value $val;
32
33    public function __construct(Value $val)
34    {
35        $this->val = $val;
36        $this->selfRef = $this;
37    }
38}
39
40for ($j = 0; $j < 10; $j++) {
41    for ($i = 0; $i < 3000; $i++) {
42        new Foo(new Value());
43    }
44}
45
46var_dump(gc_status());
47?>
48--EXPECTF--
49array(12) {
50  ["running"]=>
51  bool(false)
52  ["protected"]=>
53  bool(false)
54  ["full"]=>
55  bool(false)
56  ["runs"]=>
57  int(10)
58  ["collected"]=>
59  int(25000)
60  ["threshold"]=>
61  int(10001)
62  ["buffer_size"]=>
63  int(16384)
64  ["roots"]=>
65  int(10000)
66  ["application_time"]=>
67  float(%f)
68  ["collector_time"]=>
69  float(%f)
70  ["destructor_time"]=>
71  float(%f)
72  ["free_time"]=>
73  float(%f)
74}
75