3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // spl $SplFixedArray = new SplFixedArray(1024 * 1024); // array(); for ($i = 0; $i < 1024 * 1024; ++$i) $SplFixedArray[$i] = 0; echo 'SplFixedArray: ' . memory_get_peak_usage() . PHP_EOL; // 标准array $array = array(1024 * 1024); // array(); for ($i = 0; $i < 1024 * 1024; ++$i) $array[$i] = 0; echo 'Standard array: '.memory_get_peak_usage() . PHP_EOL;
based on nsRTH
Output for 7.2.0
SplFixedArray: 17161792 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/6Ijqb on line 12
Process exited with code 255.
Output for 7.1.0, 7.1.7 - 7.1.10
SplFixedArray: 17125184 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/6Ijqb on line 12
Process exited with code 255.
Output for 7.1.5 - 7.1.6
SplFixedArray: 17125432 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/6Ijqb on line 12
Process exited with code 255.
Output for 7.0.0 - 7.0.20
SplFixedArray: 17125232 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 33554440 bytes) in /in/6Ijqb on line 12
Process exited with code 255.
Output for 5.5.24 - 5.6.28
SplFixedArray: 58939928 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /in/6Ijqb on line 12
Process exited with code 255.
Output for 5.4.10 - 5.4.45
SplFixedArray: 58940392 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /in/6Ijqb on line 12
Process exited with code 255.
Output for 5.3.20 - 5.3.29
SplFixedArray: 59344888 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /in/6Ijqb on line 12
Process exited with code 255.