bug #25204 [DI] Clear service reference graph (nicolas-grekas)
This PR was merged into the 3.4 branch.
Discussion
----------
[DI] Clear service reference graph
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | yes (memory usage)
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
Spotted while playing with the container: we keep this graph in memory even it its stale already.
Clearing it also leave circular refs for the php garbage collector, better clean ourselves.
Commits
-------
2744b41
[DI] Clear service reference graph
This commit is contained in:
commit
ad3ddebf90
@ -159,6 +159,8 @@ class Compiler
|
||||
}
|
||||
|
||||
throw $e;
|
||||
} finally {
|
||||
$this->getServiceReferenceGraph()->clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,6 +75,9 @@ class ServiceReferenceGraph
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
foreach ($this->nodes as $node) {
|
||||
$node->clear();
|
||||
}
|
||||
$this->nodes = array();
|
||||
}
|
||||
|
||||
|
@ -107,4 +107,12 @@ class ServiceReferenceGraphNode
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all edges.
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->inEdges = $this->outEdges = array();
|
||||
}
|
||||
}
|
||||
|
@ -142,6 +142,7 @@ class PhpDumper extends Dumper
|
||||
$currentPath = array($id => $id);
|
||||
$this->analyzeCircularReferences($node->getOutEdges(), $checkedNodes, $currentPath);
|
||||
}
|
||||
$this->container->getCompiler()->getServiceReferenceGraph()->clear();
|
||||
|
||||
$this->docStar = $options['debug'] ? '*' : '';
|
||||
|
||||
|
Reference in New Issue
Block a user