Closed rieschl closed 5 years ago
Credit goes to @Xerkus for discovering it 😄
To write a test for it we would need Weakref, which is probably not possible.
To write a test for it we would need Weakref, which is probably not possible.
A test case would use memory_get_usage()
, IMO
A test case would use
memory_get_usage()
, IMO
I changed the fix (and squashed the commit) to use static
but I'm not sure if I understand PHP internals good enough to write a meaningful test using memory_get_usage()
.
Any chance someone could write a test for that so it can be merged?
@rieschl I was looking on it and really I don't know how it should work... I came up with:
public function testInit()
{
$moduleManager = $this->prophesize(ModuleManager::class);
echo PHP_EOL;
echo memory_get_usage(), PHP_EOL;
$module = new Module();
for ($i = 0; $i < 10000; ++$i) {
$module->init($moduleManager->reveal());
}
echo memory_get_usage(), PHP_EOL;
AnnotationRegistry::reset();
echo memory_get_usage(), PHP_EOL;
}
but with/without your changes results are as I would expect:
@Ocramius would you be able to help, please?
I'm ready to merge this unless someone wants to raise issue as-is.
The closure did bind to
$this
orself
and therefore couldn't be garbage collected.