fork download
  1. <?php
  2. // error.php
  3. echo 'initial: ' . (memory_get_peak_usage(false) / 1024 / 1024) . " MB \n";
  4. ini_set('display_errors', 1);
  5. $x = str_repeat(' ', 1024 * 1024); //store 1 MB to a string
  6. ini_set('memory_limit', '1535K'); //minimum of 1536K (1.5 MB) needed to display error
  7. while (true) {
  8. echo 'current: ' . (memory_get_peak_usage(false) / 1024 / 1024) . " MB\n";
  9. echo 'required: ' . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\n\n";
  10. $x .= str_repeat(' ', 1024 * 500); //store 500K more to string
  11. }
Runtime error #stdin #stdout #stderr 0s 52488KB
stdin
Standard input is empty
stdout
initial: 0.11073684692383 MB 
current: 1.1099166870117 MB
required: 1.5 MB


Fatal error: Allowed memory size of 1571840 bytes exhausted (tried to allocate 512001 bytes) in /home/jEjt5O/prog.php on line 11
stderr
PHP Fatal error:  Allowed memory size of 1571840 bytes exhausted (tried to allocate 512001 bytes) in /home/jEjt5O/prog.php on line 11