Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] Increase reserved memory for error handling (#42646)
* Increase reserved memory for error handling Follow up to #42630 The error handler should be able to report exceptions arising from exceeding the PHP memory limit. Because of changes made to error handling, the previously configured value is no longer sufficiently large. A similar change was also done in Symfony a while ago, see symfony/symfony#44327. I used the following artisan command to determine the amount of memory required for error handling, using a reporter that simply writes to a file: ```php <?php declare(strict_types=1); namespace App\Console\Commands; use Illuminate\Console\Command; final class MeasureHandlerMemory extends Command { protected $signature = 'measure-handler-memory'; private int $peak; public function handle(): void { $this->peak = memory_get_peak_usage(); trigger_error('', E_USER_ERROR); } public function __destruct() { $used = memory_get_peak_usage() - $this->peak; echo "error handling used: " . $used . "\n"; $before = memory_get_usage(); $times = 10240; $reserve = str_repeat('x', $times); $after = memory_get_usage() - $before; echo 'repeat times ' . $times . ' reserves: ' . $after . "\n"; $ratio = $after / $times; echo 'ratio between bytes and repeat: ' . $ratio . "\n"; echo 'minimum times to repeat: ' . $used / $ratio . "\n"; } } ``` * Free memory in HandleExceptions::handleShutdown() While validating the effectiveness of #42630 in our application, I found that the call `$error = error_get_last()` causes a tiny bit of memory usage. Thus, I think it is better to clear memory as soon as entering the handler. * Update HandleExceptions.php Co-authored-by: Taylor Otwell <taylor@laravel.com>
- Loading branch information