logan
logan

Reputation: 8346

How to clear or destory memories that is occupied by PHP Object

I using PHPExcel reader. Load function reads the Huge Excel and keeps memory until programs ends. This is affecting the program performance down the line.

I would like to clear the memory occupied by php object $objReader & $objPHPExcel shows in below code.

$objReader = new PHPExcel_Reader_Excel2007();
            $objReader->setReadFilter( new MyReadFilter($z) );
            $objReader->setReadDataOnly(true);
            $objPHPExcel = $objReader->load($inputFileName);
            $objSheet = $objPHPExcel->getActiveSheet();

load($inputFileName) reads the full excel file data & stores it $objPHPExcel

Upvotes: 1

Views: 1054

Answers (1)

tchow002
tchow002

Reputation: 1098

I believe you can free up the memory by disconnecting worksheets then unseting the object.

$objPHPExcel->disconnectWorksheets();
unset($objPHPExcel);

Upvotes: 5

Related Questions