Home > php教程 > php手册 > PHPExcel Allowed memory size of 内存泄漏解决办法

PHPExcel Allowed memory size of 内存泄漏解决办法

WBOY
Release: 2016-06-13 09:56:57
Original
949 people have browsed it

本文章来介绍一个关于PHPExcel Allowed memory size of 内存泄漏解决办法,有碰到此类的朋友可参考参考。

我在利用PHPExcel导入一个一个大概31列、500行的文档,实行导入之后,PHP会报如下错误:

Fatal error: Allowed memory size of 209715200 bytes exhausted (tried to allocate 35 bytes)

inX:wwwClassesPHPExcelCell.php on line 711


解决办法是在 PHPExcel_Worksheet 类中增加方法:

 代码如下 复制代码

 public function Destroy() {
     foreach($this->_cellCollection as $index => $dummy) {
         $this->_cellCollection[$index] = null;
     }
 }

并在 PHPExcel 类中增加方法:

 public function Destroy() {
     foreach($this->_workSheetCollection as $index => $dummy) {
         $this->_workSheetCollection[$index]->Destroy();
         $this->_workSheetCollection[$index] = null;
     }
 }

还有一种办法就是修改你php内存配置,在中加入

在php文件增进一条语句

 代码如下 复制代码

ini_set('memory_limit', '-1');         

ini_set('memory_limit','265M')

修改php.ini(保举)

 代码如下 复制代码

memory_limit = 12M


.htaccess文件,添加如下内容

 代码如下 复制代码

php_value memory_limit 12M

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template