Skip to content
Permalink
Browse files

Reduce memory footprint of multithreaded mode

  • Loading branch information...
muglug committed Apr 16, 2019
1 parent ff14f67 commit 282dd8e8aba1ff701b0450258447fc73ce233444
Showing with 21 additions and 0 deletions.
  1. +21 −0 src/Psalm/Internal/Codebase/Analyzer.php
@@ -226,6 +226,15 @@ function ($_, $file_path) use ($project_analyzer, $filetype_analyzers) {
$process_file_paths,
/** @return void */
function () {
$project_analyzer = ProjectAnalyzer::getInstance();
$codebase = $project_analyzer->getCodebase();
$file_reference_provider = $codebase->file_reference_provider;
$file_reference_provider->setCallingMethodReferencesToClassMembers([]);
$file_reference_provider->setFileReferencesToClassMembers([]);
$file_reference_provider->setCallingMethodReferencesToMissingClassMembers([]);
$file_reference_provider->setFileReferencesToMissingClassMembers([]);
},
$analysis_worker,
/** @return WorkerData */
@@ -235,6 +244,10 @@ function () {
$analyzer = $codebase->analyzer;
$file_reference_provider = $codebase->file_reference_provider;
if ($this->debug_output) {
echo 'Gathering data for forked process' . "\n";
}
return [
'issues' => IssueBuffer::getIssuesData(),
'file_references_to_classes'
@@ -257,12 +270,20 @@ function () {
}
);
if ($this->debug_output) {
echo 'Forking analysis' . "\n";
}
// Wait for all tasks to complete and collect the results.
/**
* @var array<int, WorkerData>
*/
$forked_pool_data = $pool->wait();
if ($this->debug_output) {
echo 'Collecting forked analysis results' . "\n";
}
foreach ($forked_pool_data as $pool_data) {
IssueBuffer::addIssues($pool_data['issues']);

0 comments on commit 282dd8e

Please sign in to comment.
You can’t perform that action at this time.