3v4l.org

run code in 300+ PHP versions simultaneously
<?php class LargeObject { protected $array; public function __construct() { $this->array = array_fill(0, 1000, 17); } public function getItemProcessor(): Closure { // Try with and without 'static' here return function () { // do some processing unrelated to $this }; } } $start = microtime(true); $processors = []; for ($i = 0; $i < 1000; $i++) { $lo = new LargeObject(); $processors[] = $lo->getItemProcessor(); } $memory = memory_get_usage() >> 20; $time = (microtime(true) - $start) * 1000; printf("This took %dms and %dMB of memory\n", $time, $memory);
Output for 8.2.14, 8.3.10 - 8.3.11, 8.5.0
This took 25ms and 20MB of memory
Output for 8.2.18 - 8.2.19, 8.3.23, 8.4.5, 8.4.11
This took 23ms and 20MB of memory
Output for 8.2.2, 8.2.5, 8.2.15, 8.3.3, 8.4.10
This took 22ms and 20MB of memory
Output for 8.2.17, 8.4.9
This took 21ms and 20MB of memory
Output for 8.2.0, 8.2.20, 8.2.22, 8.2.27, 8.4.8
This took 24ms and 20MB of memory
Output for 8.2.1, 8.2.3 - 8.2.4, 8.2.6 - 8.2.10, 8.2.23 - 8.2.26, 8.3.5, 8.3.8 - 8.3.9, 8.3.12, 8.3.15 - 8.3.17, 8.3.19 - 8.3.20, 8.3.24, 8.4.1 - 8.4.4, 8.4.7
This took 10ms and 20MB of memory
Output for 8.4.6
This took 13ms and 20MB of memory
Output for 8.3.22
This took 16ms and 20MB of memory
Output for 8.3.6, 8.3.21
This took 15ms and 20MB of memory
Output for 8.2.11, 8.3.18
This took 12ms and 20MB of memory
Output for 8.2.16, 8.3.7, 8.3.13 - 8.3.14
This took 11ms and 20MB of memory
Output for 8.2.13, 8.3.4
This took 18ms and 20MB of memory
Output for 8.3.2
This took 26ms and 20MB of memory
Output for 8.2.21, 8.2.28 - 8.2.29, 8.3.1
This took 20ms and 20MB of memory
Output for 8.3.0
This took 7ms and 20MB of memory
Output for 8.2.12
This took 17ms and 20MB of memory
Output for 8.1.33
This took 20ms and 36MB of memory
Output for 8.1.32
This took 25ms and 36MB of memory
Output for 8.1.0, 8.1.30 - 8.1.31
This took 17ms and 36MB of memory
Output for 8.1.29
This took 16ms and 36MB of memory
Output for 8.1.28
This took 34ms and 36MB of memory
Output for 8.1.2 - 8.1.27
Fatal error: Out of memory (allocated 31457280) (tried to allocate 36864 bytes) in /in/0bpD8 on line 7 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.
Output for 8.1.1
This took 18ms and 36MB of memory
Output for 7.4.9, 7.4.15, 8.0.2, 8.0.7, 8.0.22, 8.0.26 - 8.0.30
This took 17ms and 35MB of memory
Output for 7.4.21, 7.4.23, 7.4.32, 8.0.16, 8.0.25
This took 27ms and 35MB of memory
Output for 7.4.24, 8.0.23 - 8.0.24
This took 24ms and 35MB of memory
Output for 7.4.3 - 7.4.4, 7.4.8, 7.4.11, 7.4.26, 7.4.29 - 7.4.30, 8.0.6, 8.0.21
This took 16ms and 35MB of memory
Output for 8.0.18, 8.0.20
This took 40ms and 35MB of memory
Output for 7.4.6, 7.4.10, 7.4.16 - 7.4.19, 8.0.19
This took 30ms and 35MB of memory
Output for 8.0.17
This took 41ms and 35MB of memory
Output for 8.0.13, 8.0.15
This took 28ms and 35MB of memory
Output for 8.0.12, 8.0.14
This took 25ms and 35MB of memory
Output for 7.4.14, 8.0.1, 8.0.11
This took 29ms and 35MB of memory
Output for 8.0.10
This took 18ms and 35MB of memory
Output for 8.0.9
This took 42ms and 35MB of memory
Output for 7.4.12, 8.0.8
This took 23ms and 35MB of memory
Output for 7.4.2, 8.0.5
This took 32ms and 35MB of memory
Output for 7.4.5, 7.4.33, 8.0.3
This took 22ms and 35MB of memory
Output for 7.4.1, 7.4.13, 7.4.22, 7.4.28
This took 38ms and 35MB of memory
Output for 7.4.27
This took 36ms and 35MB of memory
Output for 7.4.0, 7.4.25
This took 37ms and 35MB of memory
Output for 7.4.20
This took 21ms and 35MB of memory
Output for 7.4.7
This took 33ms and 35MB of memory

preferences:
74.71 ms | 464 KiB | 5 Q