0
I’m trying to use the library’s cache system Phpexcel, but I am still getting memory overflow in my application. I need to use cache because I am generating reports with more than 100,000 records on a server with limited memory. Thus, increase the use of memory in the file php.ini would not solve my problem. I use the following code in the class constructor:
public function __construct() {
$templateFileName = $this->getTemplateFileName();
$fullPathTemplate = public_path().'/Temp/'.$templateFileName.'.xlsx';
$cacheMethod = \PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
$cacheSettings = array(
'memoryCacheSize' => '50MB'
);
if (! \PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings)) {
die($cacheMethod . " Cache invalido " . EOL);
}
\Log::info("Utilizando PHPExcel com sistema de cache.");
$objPhpReader = new \PHPExcel_Reader_Excel2007();
$this->phpExcelObject = $objPhpReader->load($fullPathTemplate);
}
I have the impression that is not enabling the cache system, the error returned in the log Laravel 4.2 is as follows:
[2016-12-06 15:38:42] production.INFO: Utilizando PHPExcel com sistema de cache. [] []
[2016-12-06 15:45:29] production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Out of memory (allocated 1857028096) (tried to allocate 8388608 bytes)' in D:\Projetos\Rel\vendor\phpoffice\phpexcel\Classes\PHPExcel\CachedObjectStorage\PHPTemp.php:65
Stack trace:
#0 [internal function]: Illuminate\Exception\Handler->handleShutdown()
#1 {main} [] []
Thank you in advance for your attention.
I think you should rethink the use of 100,000 records, the problem is that the execution of the
script
has a certain limit and this is not a problem neither of the package, nor of Laravel, but, of the amount of records, will not have to generate otherwise or less records? I believe that the cache will not help you, because it will depend on the information generated ...– novic
The problem is that the consolidated report is a requirement of the client, worse, this forecast generate Excel reports with more than 500 thousand lines, per tab.
– Leandro Paiva