Issue Bug Rejected

#89845TYPO3 Extbase: clearState not clearing much

Sven Burkert 12/04/19, 09:31 updated 12/01/20, 13:45

Description

I have an import job for scheduler written with Extbase and memory usage is really high. In TYPO3 7.6, I was able to free memory with

$this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::class)->clearState();

But after upgrading to TYPO3 9.5, “clearState” seems not to work like before, this function just frees a tiny amount of memory.

I’ve written a simple example code which demonstrates the problem. This example can run in a Extbase Controller, no need to run it in Scheduler context.

var_dump(memory_get_usage());
$v1 = $this->frontendUserRepository->findAll();
var_dump(memory_get_usage());
foreach($v1 as $vv1) {
    $a1 = $this->frontendUserRepository->findOneByUid($vv1->getUid());
}
var_dump(memory_get_usage());
$this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::class)->clearState();
var_dump(memory_get_usage());

Output is int(49190752) int(49191568) int(566560256) int(544548736): Retrieving users from the database by “findOneByUid” consumes much memory, because the objects are stored in some PHP variable and I like to free this memory. In TYPO3 7, this worked with function “clearState”.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.