3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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; echo memory_get_usage() . PHP_EOL; foreach ($test as $k => &$v) { unset($test[$k]); } echo memory_get_usage() . PHP_EOL . PHP_EOL;
Output for 7.1.0
Init: 348528 Test 1: 8745520 8745520 Test 2: 8745520 8745520 8745544
Output for 7.0.0 - 7.0.14
Init: 348552 Test 1: 8745544 8745544 Test 2: 8745544 8745544 8745568
Output for hhvm-3.10.0 - 3.12.0
Init: 2097152 Test 1: 6291456 6291456 Test 2: 6291456 6291456 6291456
Output for 5.6.0 - 5.6.28
Init: 219928 Test 1: 24718024 15918232 Test 2: 15918208 15918208 15918208
Output for 5.5.0 - 5.5.37
Init: 219928 Test 1: 24717888 15918096 Test 2: 15918096 15918096 15918096
Output for 5.4.10 - 5.4.45
Init: 220448 Test 1: 24718424 15918632 Test 2: 15918632 15918632 15918632
Output for 5.4.0 - 5.4.9
Init: 219920 Test 1: 24717992 15918144 Test 2: 15918144 15918144 15918144
Output for 5.3.11 - 5.3.29
Init: 625200 Test 1: 25123240 16323448 Test 2: 16323448 16323448 16323448
Output for 5.3.0 - 5.3.10
Init: 624896 Test 1: 25122888 16323128 Test 2: 16323128 16323128 16323128
Output for 5.2.10 - 5.2.17
Init: 83920 Test 1: 23783200 14983104 Test 2: 14983104 14983104 14983104
Output for 5.2.7 - 5.2.9
Init: 84632 Test 1: 23786112 15114368 Test 2: 15114304 15114304 15114304
Output for 5.2.6
Init: 84952 Test 1: 23786464 15114704 Test 2: 15114640 15114640 15114640
Output for 5.2.3 - 5.2.5
Init: 84952 Test 1: 23786328 15114600 Test 2: 15114536 15114536 15114536
Output for 5.2.2
Init: 82896 Test 1: 23784104 15112464 Test 2: 15112400 15112344 15112472
Output for 5.2.1
Init: 82896 Test 1: 23783080 15014096 Test 2: 15014072 15014080 15014088
Output for 5.0.0 - 5.2.0
Fatal error: Call to undefined function memory_get_usage() in /in/7Hhv3 on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /in/7Hhv3 on line 21
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in /in/7Hhv3 on line 21
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /in/7Hhv3 on line 21
Process exited with code 255.