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"; }
Output for 7.2.0 - 7.2.10
test? 384672 9623536 1425056 1425056 1425056 1425056 1425056 1425056 1425056 1425056 1425056 1425056
Output for 7.1.0 - 7.1.1, 7.1.7 - 7.1.21
test? 348064 9586928 1388448 1388448 1388448 1388448 1388448 1388448 1388448 1388448 1388448 1388448
Output for 7.1.2 - 7.1.6
test? 348296 9587160 1388680 1388680 1388680 1388680 1388680 1388680 1388680 1388680 1388680 1388680

preferences:
68.92 ms | 401 KiB | 38 Q