3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = []; $a = 1; $b = 2; for($x = 0; $x <= 100_000; $x++) $arr[] = [$a, $b]; echo "Current memory usage: " . (memory_get_usage() / 1024) . " KB\n"; echo "Peak memory usage: " . (memory_get_peak_usage() / 1024) . " KB\n";
Output for 8.4.1
Current memory usage: 23524.6953125 KB Peak memory usage: 23524.828125 KB
Output for 8.2.0 - 8.2.26, 8.3.0 - 8.3.14
Current memory usage: 23524.6796875 KB Peak memory usage: 23524.8125 KB
Output for 8.1.0 - 8.1.1, 8.1.28 - 8.1.31
Current memory usage: 41198.140625 KB Peak memory usage: 41198.2734375 KB
Output for 8.1.2 - 8.1.27
Fatal error: Out of memory (allocated 29364224) (tried to allocate 4194312 bytes) in /in/pETM9 on line 7 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.

preferences:
67.13 ms | 410 KiB | 5 Q