How to fix Fatal Error PHPExcel: Memory Limit Exhausted whil

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
raorafique
Forum Newbie
Posts: 1
Joined: Tue Jun 18, 2013 11:53 am

How to fix Fatal Error PHPExcel: Memory Limit Exhausted whil

Post by raorafique »

I am facing this problem while reading an XLSX files having 40,000 plus rows and 7 columns having 5MB+ file size with PHPExcel.

The error description is given here:

Quote:
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in .....
Can you please suggest me a solution to this problem?

Thanking you in anticipation.

Best Regards,
Rao Rafique.
User avatar
mecha_godzilla
Forum Contributor
Posts: 375
Joined: Wed Apr 14, 2010 4:45 pm
Location: UK

Re: How to fix Fatal Error PHPExcel: Memory Limit Exhausted

Post by mecha_godzilla »

Hi,

How many files are you importing (reading) into the script and how many files are you exporting (if any)? The problem might be that once you've read the first file, you need to release the memory that has been reserved for that operation - in this case, you should amend your script to import one file *only* and then use memory_get_usage() to work out exactly how much memory your script needs.

If the problem is that you are reading one file *only* and that on its own is occupying all the memory, you might need to add a PHP directive to the script to override the memory usage or script execution time values defined in your php.ini file.

HTH,

Mecha Godzilla
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: How to fix Fatal Error PHPExcel: Memory Limit Exhausted

Post by pickle »

I believe PHPExcel has a way to read in a file one row at a time, rather than loading the entire file into memory before reading.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply