mark cuve
mark cuve

Reputation: 103

How to solve PHPExcel out of memory error?

I am using PHPExcel to generate Excel reports:

The problem is that the process writing to the excel file is getting killed (due to out of memory)

What should I do? Are there any other Excel libraries available? I want a library with both read and write capabilities.

Is there another way to solve the out of memory problem?

Upvotes: 3

Views: 5686

Answers (1)

André Laszlo
André Laszlo

Reputation: 15537

I find it hard to believe that a 600kb file run through PHPExcel would fill up 600MB of memory. It's probably just the memory allocated to PHP that runs out. You can increase the memory available to PHP scripts by using one of these methods:

  • Adding memory_limit = 16M to your php.ini file (recommended, if you have access) With root access, you can use the sed util in Linux/Unix based systems, in order to increase the memory for 64M. Don't forget to properly locate your php.ini file! sed -i 's/memory_limit = .*/memory_limit = 64M/' /etc/php5/apache2/php.ini
  • Adding ini_set('memory_limit', '16M'); to your php script
  • Adding php_value memory_limit 16M to your .htaccess file in the root folder of your project

Upvotes: 1

Related Questions