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 $SplFixedArray = new SplFixedArray(1024 * 1024); // array(); for ($i = 0; $i < 1024 * 1024; ++$i) $SplFixedArray[$i] = 0; echo 'SplFixedArray: '.memory_get_peak_usage();
Output for 8.3.5 - 8.3.6
Standard array: 17169584SplFixedArray: 33946952
Output for 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Standard array: 17169584 Fatal error: Out of memory (allocated 18878464 bytes) (tried to allocate 16777216 bytes) in /in/raMDI 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: 17169584SplFixedArray: 33946936
Output for 8.1.28
Standard array: 33947272SplFixedArray: 50724624
Output for 8.1.2 - 8.1.27
Fatal error: Out of memory (allocated 18878464) (tried to allocate 33554440 bytes) in /in/raMDI 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: 33947272SplFixedArray: 50724608
Output for 8.0.17 - 8.0.30
Standard array: 33946616SplFixedArray: 50724000
Output for 8.0.0 - 8.0.16
Standard array: 33946616SplFixedArray: 50723984
Output for 7.4.3 - 7.4.33
Standard array: 33946920SplFixedArray: 50724304
Output for 7.3.16 - 7.3.33
Standard array: 33946824SplFixedArray: 50724208
Output for 7.2.29 - 7.2.33
Standard array: 33942816SplFixedArray: 50720200

preferences:
130.33 ms | 401 KiB | 139 Q