Project

General

Profile

Actions

Bug #89845

closed

TYPO3 Extbase: clearState not clearing much

Added by Sven Burkert almost 5 years ago. Updated almost 4 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2019-12-04
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.2
Tags:
typo3, extbase, memory
Complexity:
Is Regression:
Sprint Focus:

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".


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #92975: Object references are not cleared completely by using clearState - hinting at potential memory leakClosed2020-12-02

Actions
Actions

Also available in: Atom PDF