xref: /PHP-7.3/Zend/tests/bug71818.phpt (revision 47becbf1)
1--TEST--
2Bug #71818 (Memory leak when array altered in destructor)
3--INI--
4zend.enable_gc = 1
5--FILE--
6<?php
7class MemoryLeak
8{
9    public function __construct()
10    {
11        $this->things[] = $this;
12    }
13
14    public function __destruct()
15    {
16        $this->things[] = null;
17    }
18
19    private $things = [];
20}
21
22ini_set('memory_limit', '10M');
23
24for ($i = 0; $i < 100000; ++$i) {
25    $obj = new MemoryLeak();
26}
27echo "OK\n";
28?>
29--EXPECT--
30OK
31