From 08c57d5037ce6b2435a74f564c1429859b981c6d Mon Sep 17 00:00:00 2001 From: Peter Walther Date: Mon, 13 Jan 2020 15:19:57 +0200 Subject: [PATCH] backport from 0.10: read memory warn limit at shutdown to allow re-configuration see #7739ba2 --- src/Application.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Application.php b/src/Application.php index 27b56612..8a20887c 100644 --- a/src/Application.php +++ b/src/Application.php @@ -178,15 +178,13 @@ public function run(array $options = []) { * Update the PHP configuration with user defined settings. */ private function configurePhp() { - $memoryWarnLimit = php_byte_value(Config::getDefault()->get('log.warn.memory_limit', 0)); - if ($memoryWarnLimit > 0) { - register_shutdown_function(function() use ($memoryWarnLimit) { - $usedBytes = memory_get_peak_usage($real=true); - if ($usedBytes > $memoryWarnLimit) { - Logger::log('Memory consumption exceeded '.prettyBytes($memoryWarnLimit).' (peak usage: '.prettyBytes($usedBytes).')', L_WARN, ['class' => __CLASS__]); - } - }); - } + register_shutdown_function(function() { + $warnLimit = php_byte_value(Config::getDefault()->get('log.warn.memory_limit', PHP_INT_MAX)); + $usedBytes = memory_get_peak_usage($real=true); + if ($usedBytes > $warnLimit) { + Logger::log('Memory consumption exceeded '.prettyBytes($warnLimit).' (peak usage: '.prettyBytes($usedBytes).')', L_WARN, ['class' => __CLASS__]); + } + }); /* ini_set('arg_separator.output' , '&' ); ini_set('auto_detect_line_endings', 1 );