[TYPO3-mvc] massive memory consumption in task

Philipp philippwrann at gmx.at
Fri Jan 17 09:19:58 CET 2014


Hey,

I wrote a task to get different data from my project (some internals, some externals) and create a feed for a solr server.
I need to request a few thousand objects from the repository

What is the best way to do it?

Should i break it down to smaller results using limit and offset from the query object?
The models are pretty complex and i use many submodels too to build the data for solr.

The lifting is simply too heavy and i think ~5000 entities is not that much.

my current approach is like:
$objects = $this->repository->findDemanded($demand);		
	while ($object = $objects->current()) {
		$this->addObjectToReturn($object);
		$objects->next();
		$this->identityMap->unregisterObject($object);
		$this->persistenceSession->unregisterReconstitutedEntity($Object);
		$this->persistenceSession->unregisterObject($object);
	}		
	$this->persistenceManager->clearState();

but still the same problem... I though that would give some advantage over foreach ($objects->toArray)

would something like 

$objects = $this->repository->findDemanded($demand);
$count = $objects->count();
if ($count>0) {
$processed = 0;
while ($processed < $count) {
$objects = $objects->getQuery()->setLimit(50)->setOffset($proccessed)->execute()->toArray();
foreach ($objects as $object) {
$this->addObjectToReturn($object);
$processed++;
}
foreach ($objects as $object) {
$this->identityMap->unregisterObject($object);
$this->persistenceSession->unregisterReconstitutedEntity($object);
$this->persistenceSession->unregisterObject($object);
}
$this->persistenceManager->clearState();
}
}

be better? or what would be a better way?


More information about the TYPO3-project-typo3v4mvc mailing list