3v4l.org

run code in 300+ PHP versions simultaneously
<?php class NonLeakingClass { } function test(){ $ret = []; for($i=0;$i<100000;$i++){ $ret[]= new NonLeakingClass(); } return $ret; } $i=0; echo "test?".PHP_EOL; echo memory_get_usage()."\n"; while($i++<10){ if($i==1){ $a=test(); echo memory_get_usage()."\n"; unset($a); } echo memory_get_usage()."\n"; } gc_collect_cycles(); echo memory_get_usage()."\n";
Output for 7.2.0 - 7.2.2, 7.2.4 - 7.2.8, 7.2.10
test? 385136 9624000 1425520 1425520 1425520 1425520 1425520 1425520 1425520 1425520 1425520 1425520 1425520
Output for 7.2.3, 7.2.9
test? 385136
Process exited with code 137.
Output for 7.1.0 - 7.1.1, 7.1.7 - 7.1.14, 7.1.17 - 7.1.19, 7.1.21
test? 348528 9587392 1388912 1388912 1388912 1388912 1388912 1388912 1388912 1388912 1388912 1388912 1388912
Output for 7.1.15 - 7.1.16, 7.1.20
test? 348528
Process exited with code 137.
Output for 7.1.2 - 7.1.6
test? 348888 9587752 1389272 1389272 1389272 1389272 1389272 1389272 1389272 1389272 1389272 1389272 1389272

preferences:
68.38 ms | 401 KiB | 38 Q