3v4l.org

run code in 300+ PHP versions simultaneously
<?php function create() { $a = new stdClass(); $b = new stdClass(); $b->a = $a; // $b->cb = function() use ($a) { // }; $a->b = $b; return $a; } echo number_format(memory_get_peak_usage() / 1000000, 2, '.', ' '), " MB\n"; for ($i = 0; $i < 1000; ++$i) { create(); // $a->b = new ArrayObject(); } gc_collect_cycles(); echo number_format(memory_get_peak_usage() / 1000000, 2, '.', ' '), " MB\n";
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
0.43 MB 1.23 MB
Output for 7.2.0 - 7.2.33
0.42 MB 1.23 MB
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33
0.38 MB 1.19 MB
Output for 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28
0.23 MB 0.99 MB
Output for 5.3.11 - 5.3.29
0.64 MB 1.40 MB
Output for 5.3.0 - 5.3.10
0.63 MB 1.40 MB
Output for 5.2.1 - 5.2.17
0.09 MB Fatal error: Call to undefined function gc_collect_cycles() in /in/LVfuv on line 19
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0
Fatal error: Call to undefined function memory_get_peak_usage() in /in/LVfuv on line 13
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: memory_get_peak_usage() in /in/LVfuv on line 13
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Fatal error: Call to undefined function: memory_get_peak_usage() in /in/LVfuv on line 13
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: memory_get_peak_usage() in /in/LVfuv on line 13

preferences:
243.15 ms | 401 KiB | 355 Q