I have an import job for scheduler written with Extbase and memory usage is really high.
(我有一个用Extbase编写的调度程序的导入作业,内存使用率确实很高。)
In TYPO3 7.6, I was able to free memory with (在TYPO3 7.6中,我能够使用)
$this->objectManager->get(TYPO3CMSExtbasePersistenceGenericPersistenceManager::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.
(但是在升级到TYPO3 9.5之后,“ clearState”似乎无法像以前那样工作,此功能仅释放少量内存。)
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. (该示例可以在Extbase控制器中运行,而无需在Scheduler上下文中运行。)
var_dump(memory_get_usage());
$v1 = $this->frontendUserRepository->findAll();
foreach($v1 as $vv1) {
$a1 = $this->frontendUserRepository->findOneByUid($vv1->getUid());
}
var_dump(memory_get_usage());
$this->objectManager->get(TYPO3CMSExtbasePersistenceGenericPersistenceManager::class)->clearState();
var_dump(memory_get_usage());
Output is int(49013528) int(565877768) int(543894472)
: 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.
(输出为int(49013528) int(565877768) int(543894472)
:通过“ findOneByUid”从数据库中检索用户会消耗大量内存,因为对象存储在某些PHP变量中,并且我想释放此内存。)
In TYPO3 7, this worked with function "clearState". (在TYPO3 7中,它与功能“ clearState”一起使用。)
ask by Sven translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…