Skip to content

Commit

Permalink
Merge pull request #45530 from nextcloud/jtr/fix-cron-memory-usage-le…
Browse files Browse the repository at this point in the history
…vels

fix(cron): Log excess memory usage at debug and info levels
  • Loading branch information
joshtrichards authored Jun 12, 2024
2 parents b3e4270 + ecef392 commit a11262b
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 @@ -182,10 +182,10 @@
);
}

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 a11262b

Please sign in to comment.