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; print_r('Standard array: '.memory_get_peak_usage()); // spl $array = new SplFixedArray(1024 * 1024); // array(); for ($i = 0; $i < 1024 * 1024; ++$i) $array[$i] = 0; print_r('SplFixedArray: '.memory_get_peak_usage());

preferences:
61.47 ms | 402 KiB | 5 Q