473,473 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to fix Fatal Error: Memory Limit Exhausted while reading XLSX file of 5MB or High

3 New Member
Hi,

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

The error description is given here:

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.
Jun 18 '13 #1
2 3108
Atli
5,058 Recognized Expert Expert
Hey.

There are two solutions to this:
  1. Increase PHP's memory limit to accommodate the memory required to read in the whole file by setting the memory_limit configuration directive. (And note that the required memory size may well far exceed the size of the input data, depending on what's happening behind the scenes of whatever code is reading it.)

  2. Split the input file into smaller pieces. Depending on the input file, it may be possible to read the file in smaller chunks, thus avoiding having it all in memory at the same time. For instance, by using fopen() plus fgets() instead of file() or file_get_contents(). (Though this, specifically, applies more to normal text files than XLSX files.) - Otherwise you'll need to split the files up outside of PHP.
Jun 19 '13 #2
adrilo
1 New Member
I assumed that you used an open-source library like PHPExcel or SimpleXlsx. Those libraries were not designed to scale and therefore can't handle large files without consuming all the available memory or taking forever. So increasing memory_limit usually does not work (at best, that's a temporary fix).
I can suggest you to take a look at Spout: https://github.com/box/spout. It is able to read XLSX files of any size, pretty fast and does not require more than 10mb of memory.

I've used it to read multi millions rows files, and it works like a charm!
Jan 27 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Phil Powell | last post by:
Actually the client is saying it sometimes happens and sometimes doesn't happen, and when they refresh their screen it clears itself (I assume the memory clears). Here is line 1135: $result =...
2
by: Gonzalo | last post by:
Just upgraded php (5.0.3) - compiled from source. I'm trying to upgrade & install some Pear packages but get the following error: $ pear upgrade pear downloading PEAR-1.3.5.tgz ... Starting...
9
by: Marco Nova | last post by:
Hello I'm using the latest version of Visual Studio 2003 version 7.1.3088, .net framework 1.1.4322 and I've some problem compiling a project, it give me the error ...
3
by: Dave Smithz | last post by:
Hi there, I changed one of my MySQL search queries to allow a situation where the user gets much more information returned. However, it has now given me the error message: Fatal error: Allowed...
3
by: f.amann | last post by:
hi there! i save images in a mysql db and i wrote a script called getimage.php to display them. in my getimage.php i want to resize my images to display them as thumbnails but there always...
1
by: rookie C Prog | last post by:
Guys, below is my code. I have created the directory, I have made sure it is not read only. But still kicks out fatal error C1083: Cannot open precompiled header file: 'Debug/Ch 2 Ex 14.pch':...
1
by: Kimmo Laine | last post by:
Hi! We've encountered a strange problem concerning memory usage. In the previous install the maximum memory amount per page was limited to 8 MB and it was never reached. Now, after upgrading...
1
by: santrooper | last post by:
Hello all, I am trying to unpack big wav file (more than 10 mb), because i want to generate Visualization of an wav file, for smaller files (less than 2 mb) it works fine, but for bigger files it...
1
by: RYKLOU | last post by:
I am kinda new to php, but i do know what i am doing kinda, but i came across this error when i am trying to upload a file to my website. Fatal error: Allowed memory size of 8388608 bytes...
1
by: Tuyet | last post by:
I am on a web server: IIS 6, PHP 5.3 and MySQL. I received this fastcgi error: FastCGI Error The FastCGI Handler was unable to process the request. ________________________________________...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.