Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions core/Service/CronService.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,21 +226,33 @@ private function runCli(string $appMode, ?array $jobClasses): void {
['app' => 'cron']
);
}

if ($memoryIncrease > 50 * 1024 * 1024) {
$message = 'Memory leak detected after executing job ' . $jobDetails . '. Memory usage grew by ' . Util::humanFileSize($memoryIncrease) . '.';
if ($jobMemoryPeak > (300 * 1024 * 1024)) {
$message
= 'Cron job used more than 300 MiB of RAM after executing job '
. $jobDetails
. ': '
. Util::humanFileSize($jobMemoryPeak)
. ')';
$this->logger->warning($message, ['app' => 'cron']);
$this->verboseOutput($message);
}
if ($jobMemoryPeak > 300 * 1024 * 1024) {
$message = 'Cron job used more than 300 MiB of RAM after executing job ' . $jobDetails . ': ' . Util::humanFileSize($jobMemoryPeak) . ')';

// Clean-up
$this->setupManager->tearDown();
$this->tempManager->clean();

if ($memoryIncrease > (50 * 1024 * 1024)) {
$message
= 'Memory leak detected after executing job '
. $jobDetails
. '. Memory usage grew by '
. Util::humanFileSize($memoryIncrease)
. '.';
$this->logger->warning($message, ['app' => 'cron']);
$this->verboseOutput($message);
}

// clean up after unclean jobs
$this->setupManager->tearDown();
$this->tempManager->clean();
// Check forgotten transaction
if ($this->connection->inTransaction()) {
$this->connection->rollBack();
$message = 'Cron job left a transaction opened after executing job ' . $jobDetails . '. The transaction was rolled back.';
Expand Down
Loading