[FLOW3-general] Possible Memory Problem within Flow3

Chris Zepernick chris at swift-lizard.com
Tue Nov 29 13:20:13 CET 2011


Hi guys,

we discovered a slight little problem here:

public function InsertRecordsCommand(){
   for($i = 0; $i < 60000; $i++){
     $model = new \SwiftLizard\Blog\Domain\Model\Blog();
     $model->setName('Chris Evil Test ' . $i);
   }
}

This is a method implemented in a command controller, the problem is 
that in "normal" php with this implementation will show a constant 
memory usage, within FLOW3 the memory usage increases with each iteration.

What we discovered within our debugging is that this is due to this code 
in the created cache class:

$advices = 
$this->FLOW3_AOP_Proxy_targetMethodsAndGroupedAdvices['__construct']['TYPO3\FLOW3\AOP\Advice\BeforeAdvice'];

$joinPoint = new \TYPO3\FLOW3\AOP\JoinPoint($this, 
'SwiftLizard\Blog\Domain\Model\Blog', '__construct', $methodArguments);
foreach ($advices as $advice){
   $advice->invoke($joinPoint);
}

To be specific "$advice->invoke($joinPoint);".

This call creates, at least this is what i got as error message the time 
I turned that line into a comment, the persistence identifier and adds 
the object to \TYPO3\FLOW3\Core\Bootstrap::$staticObjectManager.

My question is why is this done on __construct of an entity?

As far as I get it the identifier is only needed at persist of an object.

Second Question is why is each instance of an entity stored into
\TYPO3\FLOW3\Core\Bootstrap::$staticObjectManager ?

This would be a second storage for the same object besides the entities 
repository, and at the moment I can find no way to unset an object that 
was created by new Bla(); Wich increases memory usage at bulk jobs to a 
level where one runs into a memory leak.

Last Question is more general, we discovered that the detach() method 
from Doctrine has not yet been implemented into the standard repository 
for entities, to my mind this would make a lot of sense in case one 
would like to CUD (Create, Update, Delete) a lot of entities at once.

Was there a reason to miss that ?

Thanks for your help.

Chris


More information about the FLOW3-general mailing list