<?php
// error.php
echo 'initial: ' . (memory_get_peak_usage(false) / 1024 / 1024) . " MB \n";
error_reporting(E_ALL);
ini_set('display_errors', 1);
$x = str_repeat(' ', 1024 * 1024); //store 1 MB to a string
ini_set('memory_limit', '1535K'); //minimum of 1536K (1.5 MB) needed to display error
while (true) {
    echo 'current: ' . (memory_get_peak_usage(false) / 1024 / 1024) . " MB\n";
    echo 'required: ' . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\n\n";
    $x .= str_repeat(' ', 1024 * 500); //store 500K more to string
}