@ 2021-05-22T09:08:33Z <?php
echo sprintf("\n%.1fMB", memory_get_usage(true) / 1024 / 1024);
// allocate a large byte string of around 5 MB
$a = str_repeat("0", 5 * 1024 * 1024);
echo sprintf("\n%.1fMB", memory_get_usage(true) / 1024 / 1024);
// setting the memory limit lower than the current is accepted
ini_set("memory_limit", "3M");
echo sprintf("\n%.1fMB", memory_get_usage(true) / 1024 / 1024);
// further allocation beyond the limit
$b = str_repeat("0", 5 * 1024 * 1024);
echo sprintf("\n%.1fMB", memory_get_usage(true) / 1024 / 1024);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.4.21 , 8.0.8 , 8.1.1 2.0MB
7.0MB
Warning: Failed to set memory limit to 3145728 bytes (Current memory usage is 7344128 bytes) in /in/egq60 on line 9
7.0MB
12.0MB Output for 7.3.10 - 7.3.29 , 7.4.0 - 7.4.20 , 8.0.0 - 8.0.7 2.0MB
7.0MB
7.0MB
12.0MB Output for 7.3.0 - 7.3.9 2.0MB
7.0MB
7.0MB
Fatal error: Allowed memory size of 3145728 bytes exhausted (tried to allocate 5242912 bytes) in /in/egq60 on line 13
Process exited with code 255 . preferences:dark mode live preview ace vim emacs key bindings
56.77 ms | 408 KiB | 5 Q