3v4l.org

run code in 300+ PHP versions simultaneously
<?php class X { public $r; public $r2; public function __destruct() { $this->r2 = null; } } function getCircle() { $a = new X(); $b = new X(); $c = new X(); $a->r = $c; $b->r = $a; $c->r = $b; return $a; } $zeroMemory = memory_get_usage(); $u = getCircle(); $u->r2 = getCircle(); $u = null; gc_collect_cycles(); var_dump(memory_get_usage()- $zeroMemory);
Output for 7.3.0 - 7.3.31, 8.1rc1 - rc2
int(0)
Output for 7.4.0 - 7.4.24, 8.0.0 - 8.0.11
int(480)

preferences:
40.67 ms | 460 KiB | 5 Q