Skip to content

Commit

Permalink
fixed running cron module when memory limit set to -1
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmannmartin committed Dec 27, 2023
1 parent a33240e commit 30167cb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Component/Cron/CronModuleExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ public function canRun(CronModuleConfig $cronConfig): bool
);

$memoryUsage = memory_get_usage(true);
$memoryLimit = BytesHelper::getPhpMemoryLimitInBytes();

if ($memoryUsage >= BytesHelper::getPhpMemoryLimitInBytes() * 0.9) {
if ($memoryLimit !== -1 && $memoryUsage >= $memoryLimit * 0.9) {
$this->logger->info('Cron was running out of memory, so it was put to sleep to prevent failure.');

return false;
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Component/Bytes/BytesHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function testConvertPhpStringByteDefinitionToBytes(string $phpStringBytes
public function phpStringBytesToBytesDataProvider(): array
{
return [
['phpStringBytes' => '-1', 'expectedBytes' => -1],
['phpStringBytes' => '12', 'expectedBytes' => 12],
['phpStringBytes' => '12K', 'expectedBytes' => 12288],
['phpStringBytes' => '12M', 'expectedBytes' => 12582912],
Expand Down

0 comments on commit 30167cb

Please sign in to comment.