3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo "Init: ".memory_get_usage() . PHP_EOL . PHP_EOL; $test = $test2 = array(); $i = 0; while ($i++ < 100000) { $test[] = $i; $test2[] = $i; } // test loop 1 echo "Test 1: ".memory_get_usage() . PHP_EOL; foreach ($test as $k => $v) { unset($test[$k]); } echo memory_get_usage() . PHP_EOL . PHP_EOL; // test loop 2 echo "Test 2: ".memory_get_usage() . PHP_EOL; foreach ($test2 as $k => &$v) { unset($test2[$k]); } echo memory_get_usage() . PHP_EOL . PHP_EOL;
Output for 5.4.10 - 5.4.45
Init: 220216 Test 1: 24718320 15918496 Test 2: 15918496 2318312
Output for 5.4.0 - 5.4.9
Init: 219688 Test 1: 24717656 15917864 Test 2: 15917864 2317784
Output for 5.3.11 - 5.3.29
Init: 624768 Test 1: 25122792 16323000 Test 2: 16323000 2722880
Output for 5.3.0 - 5.3.10
Init: 624464 Test 1: 25122456 16322696 Test 2: 16322696 2722576

preferences:
77.01 ms | 401 KiB | 80 Q