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().'<br>'; // 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: 17169608<br>SplFixedArray: 33946976
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: 17169608<br>SplFixedArray: 33946976
Output for 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Standard array: 17169608<br> Fatal error: Out of memory (allocated 18878464 bytes) (tried to allocate 16777216 bytes) in /in/e0RD3 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: 17169608<br>SplFixedArray: 33946960
Output for 8.1.28
Standard array: 33947296<br>SplFixedArray: 50724648
Output for 8.1.2 - 8.1.27
Fatal error: Out of memory (allocated 18878464) (tried to allocate 33554440 bytes) in /in/e0RD3 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: 33947296<br>SplFixedArray: 50724632
Output for 8.0.17 - 8.0.30
Standard array: 33946640<br>SplFixedArray: 50724024
Output for 8.0.0 - 8.0.16
Standard array: 33946640<br>SplFixedArray: 50724008
Output for 7.4.0 - 7.4.33
Standard array: 33946944<br>SplFixedArray: 50724328
Output for 7.3.0 - 7.3.33
Standard array: 33946848<br>SplFixedArray: 50724232
Output for 7.2.0 - 7.2.4, 7.2.6, 7.2.8, 7.2.10 - 7.2.33
Standard array: 33942968<br>SplFixedArray: 50720352
Output for 7.2.7, 7.2.9

Process exited with code 137.
Output for 7.2.5
Standard array: 33942968<br>
Process exited with code 137.
Output for 7.1.25 - 7.1.33
Standard array: 33906296<br>SplFixedArray: 50683680
Output for 7.1.0, 7.1.7 - 7.1.20
Standard array: 33906368<br>SplFixedArray: 50683752
Output for 7.1.5 - 7.1.6
Standard array: 33906544<br>SplFixedArray: 50683928
Output for 7.0.0 - 7.0.20
Standard array: 33906400<br>SplFixedArray: 50683800
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/e0RD3 on line 5
Process exited with code 255.

preferences:
172.95 ms | 402 KiB | 228 Q