PHPExcel Allowed memory size of memory leakage solution

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.