3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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());
based on pFSql
Output for 7.2.0
Standard array: 33943056SplFixedArray: 50720440
Output for 7.1.0, 7.1.7 - 7.1.10
Standard array: 33906416SplFixedArray: 50683800
Output for 7.1.5 - 7.1.6
Standard array: 33906656SplFixedArray: 50684040
Output for 7.0.0 - 7.0.20
Standard array: 33906448SplFixedArray: 50683848
Output for 5.3.20 - 5.6.28
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /in/A3c9u on line 5
Process exited with code 255.