【发布时间】:2016-10-09 01:54:09
【问题描述】:
我正在 TYPO3 CMS 6.2 Extbase 中编写一个扩展函数,它必须处理大型存储库中的每个对象。如果我有大约 10,000 个对象,我的函数可以正常工作,但如果我有超过 20,000 个对象,则内存不足。如何处理更大的存储库?
$importRecordsCount = $this->importRecordRepository->countAll();
for ($id = 1; $id <= $importRecordsCount; $id++) {
$importRecord = $this->importRecordRepository->findByUid($id);
/* Do things to other models based on properties of $importRecord */
}
程序在通过上面的findByUid() 行后,在TYPO3\CMS\Core\Utility\GeneralUtility::instantiateClass( ) 中超出了..\GeneralUtility.php:4427 附近的内存。在我最近的测试中,出现此错误需要 117 秒。错误信息是:
致命错误:在 ... \typo3\sysext\core\Classes\Utility\GeneralUtility.php 第 4448 行中已用尽 134217728 字节的允许内存大小(尝试分配 4194304 字节)
如果重要的话,我不使用@lazy,因为我稍后会在函数中进行一些处理。
【问题讨论】:
标签: typo3 extbase typo3-6.2.x