Explainable PHP memory limit problem?

Posted on 2014-08-22
Last Modified: 2014-08-30
Hi experts,

I have a strange problem with my own php script. I run my own php forum and just changed some code. The main topic view page does a lot of things and during I work on my script I started getting problems with Firefox to open the page. The browser start loading sometimes and just freeze for a moment or just open a white page with no errors.

My code contain mainly php,html and some javascript so I started debugging by taking things out and see if it works. The problem seem not my code because I could take random things away and everything worked and place the code again to take something else out and it worked also. but never together... Based on this I checked my apache error_log and find the error:

PHP Fatal error:  Allowed memory size of 8077888 bytes exhausted (tried to allocate 222519 bytes) in Unknown on line 0

But when I check my php.ini I do have configured 128MB as memory limit. When I test phpinfo(); in the same script / directory etc. I get also the information that I have 128 MB configured. I also tried:

echo 'Memory Limit = ' . ini_get('memory_limit') . "\n";

which as well return 128MB in the beginning of my code and at the bottom as well (in case some include etc. mess the code up).

I keep getting the error of the exhausted memory limit but only for this file (everything else works).
The odd thing to me is that this is not happening for google chrome browser. If I open the same page with google chrome the page opens normal and my apache log does not register any error but in Firefox I cant open the site (all white) and the apache error log shows the memory limit error.

I really don't know what to do and appreciate in advance any tips and help to solve this mystery.

Question by:Oliver2000
    LVL 82

    Expert Comment

    by:Dave Baldwin
    I've been getting a few 'white pages' with Firefox 31 recently here on E-E.  Are you running Firefox on the same machine as the web server?  I'm wondering if Firefox is using up all the available memory and not leaving enough for PHP.  How much RAM do you have on that machine?

    Author Comment


    I'm working with my local computer but the server is external developer machine. Also this happen not only from my but also from friends pc. Same situation.

    The developer machine is dedicated Linux server with 8GB memory RAM.
    LVL 58

    Expert Comment

    Have you tried the simple step of increasing your memory?
    Something is eating memory up, have your tried Xdebug - it may help you narrow down the offending script.
    LVL 33

    Expert Comment

    greetings Oliver2000, , ever since I updated firefox to ver 31, I have trouble with loading pages on several web sites, Today it could not load the Yahoo page at all, the day before the yahoo page would never stop loading, although it did show properly. I am guessing this may have something to do with your problem. I figure that firefox is scrambling the URL components so the POST is not correct and therefore may effect the servers responding correctly? ? But this is a WILD GUESS, on my part, since it may be only internal to firefox programming, and not on server?, , did a web search and not find much on version 31, and problems, but my search terms may need to be better. But server side processes are usually totally separate from the browser, except through the URL info sent.
    LVL 82

    Expert Comment

    by:Dave Baldwin
    Unless your version of Firefox is corrupted, I doubt that Firefox is causing your problem.  I use Firefox 31 everyday designing forms and doing POSTs without any problems.  The main difference I see between Firefox and Chrome is that Chrome is a lot faster sometimes.

    In addition, Firefox on your computer can not cause a memory problem on the server, especially one that fails at 8MB when you are supposed to have 128MB available.
    LVL 61

    Expert Comment

    Is apache using same php.ini as you are editing?

    Author Comment

    @gary: The server has enough memory and in php.ini is 128MB configured. also phpinfo and  ini_get('memory_limit') show 128MB. I try in the moment xdebugger but dont know how to use until now to find such a problem.

    @gheist: yes, 100%. As I wrote before phpinfo and  ini_get('memory_limit') both show 128MB limit but the scripts die at 8MB anyway. even if I ad  ini_get('memory_limit') in exactly the script I use I get 128MB but it still breaks down at 8MB with php fatal error for memory exhausted.

    @everybody: I was be able to switch off the problem by switching of gzip compression for this file. Like this the php interpreter dont spit out any error but the side loads hangs during load. At first all appear fast... suddenly firefox gets unresponsive for 10-20 seconds, than continue and load the rest of the side. But again, this happen not in google chrome. I try to debug with xdebugger and other tools.

    I keep you guys posted and any tip on how to use xdebug best in this case are welcome. I installed webgrind and xdebug already, I use xdebug_start_trace and profiler and I get a log file on my server but did not get webgrind to read it yet. I am on it as we speak...

    Accepted Solution

    Found the problem!

    As it turns out this was caused by a bug in jquery in combination with foundation 5 tooltips. There is some bug which stalls the entire page load if you use to many tooltips in one page. Since this was the topicview of a forum this site contained a bunch of tooltips (for each post) and there for hit this bug. Once I switched the tooltips off everything works.

    I found this with firebug event handler where the took amazing long. Once I figured it could be and foundation I found the bug reports.

    This might be not a problem for google chrome but for firefox. I dont know how this all combined to bring up the php memory exhaust error even with all the free memory but it works now perfecly since I took the tooltip out.

    thanks everybody for your tips

    Author Comment

    The error was unrelated to the tips but I found the solution for myself.

    Author Closing Comment

    I figured it our myself.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: Create Mobile App Prototypes with Adobe XD

    This is a project-based course: we go through all the steps of creating a prototype from start to finish, using all the tools and features currently available in Adobe XD. You can complete the course in less than a day, plus all project files and fonts are included.

    Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
    Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now