3v4l.org

run code in 300+ PHP versions simultaneously
<?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;
Output for 8.3.5 - 8.3.6
SplFixedArray: 17165592 Standard array: 33947016
Output for 8.3.0 - 8.3.4
SplFixedArray: 17165592 Fatal error: Out of memory (allocated 27267072 bytes) (tried to allocate 16777224 bytes) in /in/6Ijqb on line 12 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.
Output for 8.2.18
SplFixedArray: 17165576 Standard array: 33947000
Output for 8.2.0 - 8.2.17
SplFixedArray: 17165576 Fatal error: Out of memory (allocated 27267072 bytes) (tried to allocate 16777224 bytes) in /in/6Ijqb on line 12 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.
Output for 8.1.28
SplFixedArray: 17166048 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 8.1.4 - 8.1.27
SplFixedArray: 17166048 Fatal error: Out of memory (allocated 27267072) (tried to allocate 16777224 bytes) in /in/6Ijqb on line 12 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.
Output for 8.1.2 - 8.1.3
SplFixedArray: 17166032 Fatal error: Out of memory (allocated 27267072) (tried to allocate 16777224 bytes) in /in/6Ijqb on line 12 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.
Output for 8.1.0 - 8.1.1
SplFixedArray: 17166032 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 8.0.17 - 8.0.30
SplFixedArray: 17165360 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 8.0.0 - 8.0.12, 8.0.14 - 8.0.16
SplFixedArray: 17165344 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 8.0.13
SplFixedArray: 17165344 Standard array: 50723984
Output for 7.4.0 - 7.4.33
SplFixedArray: 17165664 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.3.32 - 7.3.33
SplFixedArray: 17165568 Standard array: 50724208
Output for 7.3.16 - 7.3.31
SplFixedArray: 17165568 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.2.29 - 7.2.33
SplFixedArray: 17161752 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.2.0 - 7.2.6
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.20
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.5.35, 5.6.8 - 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.

preferences:
142.65 ms | 402 KiB | 183 Q