This article introduces how to solve the memory leakage of PHPExcel Allowed memory size of. If you have such problems, refer.
After I use PHPExcel to import a document containing about 31 columns and 500 rows, PHP reports the following error:
Fatal error: Allowed memory size of 209715200 bytes exhausted (tried to allocate 35 bytes)
Authorization: wwwClassesPHPExcelCell. php on line 711
SolutionIs to add the method in the PHPExcel_Worksheet class:
The Code is as follows: |
Copy code |
Public function Destroy (){ Foreach ($ this-> _ cellCollection as $ index => $ dummy ){ $ This-> _ cellCollection [$ index] = null; } } Add the following methods to the PHPExcel class: Public function Destroy (){ Foreach ($ this-> _ workSheetCollection as $ index => $ dummy ){ $ This-> _ workSheetCollection [$ index]-> Destroy (); $ This-> _ workSheetCollection [$ index] = null; } } |
Another way is to modify your php memory configuration and add
Add a statement to the PHP File
The Code is as follows: |
Copy code |
Ini_set ('memory _ limit ','-1 '); Or Ini_set ('memory _ limit ', '265m ') |
Modify php. ini)
The Code is as follows: |
Copy code |
Memory_limit = 12 M |
Add the following content to the. htaccess file:
The Code is as follows: |
Copy code |
Php_value memory_limit 12 M |