Why so much memory uses Yii2-excel files xlsx format?

Download the file in the xlsx format

$file = UploadedFile::getInstance($this, 'file');
$data = Excel::import($file->tempName);

The file weighs 1MB the script runs for a very long time sometimes gives an error about lack of memory

Download in xls format everything works OK, why so, although the data in the files are the same
April 3rd 20 at 18:23
3 answers
April 3rd 20 at 18:25
1. Refrain when working with Excel data in the form of objects - pass simple arrays. This will greatly reduce the memory, especially if you are using AR.
2. Use queues and console application. A console application has no limits on memory and duration.
April 3rd 20 at 18:27
xlsx is just a zip archive with a bunch of things complicated. That the file is 1MB - it literally means nothing. To parse this file into components need quite a lot of memory. In nutriance yuzaetsya PHPOffice/PhpSpreadsheet , each cell of your document is an object, that count))

If you direct all critical memory - can take a serious look at converting xlsx -> csv (here processes everything you need) ->. xlsx
on the server 32гига more memory - Elza_Stanton13 commented on April 3rd 20 at 18:30
@Elza_Stanton13, so? The memory of the php process you also have 32gb? - winnifred_Ondricka commented on April 3rd 20 at 18:33
@Elza_Stanton13, well yii question is irrelevant.
Without using yii as well long processed file? - Camren_Emmerich69 commented on April 3rd 20 at 18:36
ini_set("memory_limit", "-1"); - Elza_Stanton13 commented on April 3rd 20 at 18:39
I already fgetcsv brake (null loop 150K rows > 7 seconds), and You ask why so much memory
slow class, which is 1000 times smarter. - Adolf.Ko commented on April 3rd 20 at 18:42
@Elza_Stanton13, you have balls of steel. If I understand correctly oom killer ciset process. Can netunity at the same time with ini_set("memory_limit", "-1");and to prepare for the downfalls of the server.

And if the case, spend profiling (https://tideways.com/profiler/xhprof-for-php7 ) on the document with which you are falling, you probably will be rested in PHPOffice/PhpSpreadsheet. If this is the case - control research at the library, maybe something can be accelerated independently and issue on github to saw.
Also look for analogues in this library, can they eat for less.
If all research is a failure - congratulations, you ran into the limits of php implementations work with xlsx. Either change the language or try to connect the implementation of the work with xlsx in another language. - winnifred_Ondricka commented on April 3rd 20 at 18:45
April 3rd 20 at 18:29
Read Excel I recommend to use the package (in composer "phpoffice/phpspreadsheet")
It pieces (e.g., 500 rows) to read the file, then memory issues will not.

Find more questions by tags Yii