3v4l.org

run code in 300+ PHP versions simultaneously
<?php // 标准array $array = array(1024 * 1024); // array(); for ($i = 0; $i < 1024 * 1024; ++$i) $array[$i] = 0; echo 'Standard array: '.memory_get_peak_usage(); // spl $array = new SplFixedArray(1024 * 1024); // array(); for ($i = 0; $i < 1024 * 1024; ++$i) $array[$i] = 0; echo 'SplFixedArray: '.memory_get_peak_usage();
Output for 8.3.6
Standard array: 17169576SplFixedArray: 33946944
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Standard array: 17169576SplFixedArray: 33946944
Output for 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Standard array: 17169576 Fatal error: Out of memory (allocated 18878464 bytes) (tried to allocate 16777216 bytes) in /in/pFSql on line 10 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.
Output for 8.2.18
Standard array: 17169576SplFixedArray: 33946928
Output for 8.1.28
Standard array: 33947264SplFixedArray: 50724616
Output for 8.1.2 - 8.1.27
Fatal error: Out of memory (allocated 18878464) (tried to allocate 33554440 bytes) in /in/pFSql on line 5 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
Standard array: 33947264SplFixedArray: 50724600
Output for 8.0.17 - 8.0.30
Standard array: 33946608SplFixedArray: 50723992
Output for 8.0.0 - 8.0.16
Standard array: 33946608SplFixedArray: 50723976
Output for 7.4.0 - 7.4.33
Standard array: 33946912SplFixedArray: 50724296
Output for 7.3.16 - 7.3.33
Standard array: 33946816SplFixedArray: 50724200
Output for 7.2.29 - 7.2.33
Standard array: 33942808SplFixedArray: 50720192
Output for 7.2.0 - 7.2.6
Standard array: 33942848SplFixedArray: 50720232
Output for 7.1.0, 7.1.7 - 7.1.20
Standard array: 33906208SplFixedArray: 50683592
Output for 7.1.5 - 7.1.6
Standard array: 33906384SplFixedArray: 50683768
Output for 7.0.0 - 7.0.20
Standard array: 33906240SplFixedArray: 50683640
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /in/pFSql on line 5
Process exited with code 255.

preferences:
158.87 ms | 402 KiB | 183 Q