Skip to content

Commit

Permalink
fix(cron): Log excess memory usage at debug and info levels
Browse files Browse the repository at this point in the history
Signed-off-by: Josh <josh.t.richards@gmail.com>
  • Loading branch information
joshtrichards authored and nickvergessen committed Jun 11, 2024
1 parent 81e90ae commit 8ee070c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@
$memoryAfter = memory_get_usage();
$memoryPeakAfter = memory_get_peak_usage();

if ($memoryAfter - $memoryBefore > 10_000_000) {
$logger->warning('Used memory grew by more than 10 MB when executing job ' . $jobDetails . ': ' . Util::humanFileSize($memoryAfter). ' (before: ' . Util::humanFileSize($memoryBefore) . ')', ['app' => 'cron']);
if ($memoryAfter - $memoryBefore > 50_000_000) {
$logger->warning('Used memory grew by more than 50 MB when executing job ' . $jobDetails . ': ' . Util::humanFileSize($memoryAfter). ' (before: ' . Util::humanFileSize($memoryBefore) . ')', ['app' => 'cron']);
}
if ($memoryPeakAfter > 300_000_000) {
if ($memoryPeakAfter > 300_000_000 && $memoryPeakBefore <= 300_000_000) {
$logger->warning('Cron job used more than 300 MB of ram after executing job ' . $jobDetails . ': ' . Util::humanFileSize($memoryPeakAfter) . ' (before: ' . Util::humanFileSize($memoryPeakBefore) . ')', ['app' => 'cron']);
}

Expand Down

0 comments on commit 8ee070c

Please sign in to comment.