Skip to content

Commit

Permalink
backport from 0.10: read memory warn limit at shutdown to allow re-co…
Browse files Browse the repository at this point in the history
…nfiguration

see #7739ba2
  • Loading branch information
rosasurfer committed Jan 13, 2020
1 parent 7658a68 commit 08c57d5
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 08c57d5

Please sign in to comment.