Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Dec 18, 2021
1 parent b4945ec commit fed28bc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Command/CommandHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use PHPStan\DependencyInjection\LoaderFactory;
use PHPStan\DependencyInjection\NeonAdapter;
use PHPStan\ExtensionInstaller\GeneratedConfig;
use PHPStan\File\CouldNotReadFileException;
use PHPStan\File\FileFinder;
use PHPStan\File\FileHelper;
use PHPStan\File\FileReader;
Expand Down Expand Up @@ -316,10 +317,16 @@ public static function begin(

$memoryLimitFile = $container->getParameter('memoryLimitFile');
if ($manageMemoryLimitFile && is_file($memoryLimitFile)) {
$memoryLimitFileContents = FileReader::read($memoryLimitFile);
$errorOutput->writeLineFormatted('PHPStan crashed in the previous run probably because of excessive memory consumption.');
$errorOutput->writeLineFormatted(sprintf('It consumed around %s of memory.', $memoryLimitFileContents));
$errorOutput->writeLineFormatted('');

try {
$memoryLimitFileContents = FileReader::read($memoryLimitFile);
$errorOutput->writeLineFormatted(sprintf('It consumed around %s of memory.', $memoryLimitFileContents));
$errorOutput->writeLineFormatted('');
} catch (CouldNotReadFileException $e) {
// pass
}

$errorOutput->writeLineFormatted('');
$errorOutput->writeLineFormatted('To avoid this issue, allow to use more memory with the --memory-limit option.');
@unlink($memoryLimitFile);
Expand Down

0 comments on commit fed28bc

Please sign in to comment.