PHPExcelAllowedmemorysizeof memory leakage solution _ PHP Tutorial

Source: Internet
Author: User
PHPExcelAllowedmemorysizeof memory leakage solution. This article introduces a solution for PHPExcelAllowedmemorysizeof memory leakage. if you have such problems, refer. I am using PHPExcel to import about 31 columns one by one. This article introduces a solution for memory leakage in PHPExcel Allowed memory size. if you encounter 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:

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:

Ini_set ('memory _ limit ','-1 ');

Or

Ini_set ('memory _ limit ', '265m ')

Modify php. ini)

The code is as follows:

Memory_limit = 12 M


Add the following content to the. htaccess file:

The code is as follows:

Php_value memory_limit 12 M

Memory Allowed memory size of memory leakage solution. if you encounter such problems, refer. I'm using PHPExcel to import about 31 columns one by one ,...

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.