php使用phpexcel读取excel的时候,如果excel本身行列较多,很容易引起
Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes)
内存不够的报错,
于是我写了一段脚本,利用phpexcel过滤器实现块级读取,但是每次读取完毕了,占用的内存不会释放掉,造成多次读取以后还是会报出Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes)内存不够的错误?
使用unset,=null都没有明显的作用,后面查了下资料,
在PHPExcel_Worksheet和phpexcel类中加了Desroty方法,并且显式调用也没有用
public function Destroy() {
foreach($this->_cellCollection as $index => $dummy) {
$this->_cellCollection[$index] = null;
}
$this->_cellCollection = null;
}
public function Destroy() {
foreach($this->_workSheetCollection as $index => $dummy) {
$this->_workSheetCollection[$index]->Destroy();
$this->_workSheetCollection[$index] = null;
}
$this->_workSheetCollection = null;
}
请问哪位大佬有解决方案啊?
已找到解决问题答案,每次load完excel文件并且读取完成以后,用load产生的phpexcel对象调用一下phpexcel本身提供的disconnectWorksheets()方法,会为phpexcel的属性赋予null值,释放内存资源