Solved

PHP Fatal error: Out of memory

Posted on 2010-09-16
10
899 Views
Last Modified: 2013-12-13
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.
________________________________________
Error Details:
•      The FastCGI process exceeded configured activity timeout
•      Error Number: 258 (0x80070102).
•      Error Description: The wait operation timed out.
HTTP Error 500 - Server Error.
Internet Information Services (IIS)

So I have my admin set the following:

php.ini:
Max_execution_time = 1800

Fcgiext.ini:
RequestTimeout=1800
ActivityTimeout=1200
InstanceMaxRequests=10000
EnvironmentVars=PHP_FCGI_MAX_REQUESTS:10000

Then, I got this error:

PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 469342568 bytes)

So, then I have him increase the memory_limit for php.ini to 1G.
But I am still running an out of memory problem.  I am retrieving data from a table that have over 600K records.

My php page:

$mysqli = @new mysqli('localhost', 'user', 'pass!', 'database');

$sql = "select * from table";
if($result = $mysqli->query($sql))
{
    echo '<pre>';
    var_dump($result );
    echo '</pre>';

}
else
{
      die("Error in adding investor address: ".$sql." ==> ".$mysqli->error);
}

die("help!");
0
Comment
Question by:bigjdve
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
10 Comments
 
LVL 12

Assisted Solution

by:Rok-Kralj
Rok-Kralj earned 250 total points
ID: 33696903
600k records, that is a lot. One GB is not enough. Set the limit to at least 3GB, depending on how many columns you have.
0
 
LVL 10

Expert Comment

by:mstrelan
ID: 33698079
Do you really need 600 000 records available at one time? It sounds like you could probably address this by doing less.
0
 
LVL 3

Author Comment

by:bigjdve
ID: 33702376
I know 600K of records is crazy.  But I have to work with that table until I create a new database schema and be able to use that schema.  That will not happen for a while so I have to assume that I am stuck with that table with 600K records.  Is there some configuration that I can do to ensure that I don't run into this memory limitation in the future?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Assisted Solution

by:mstrelan
mstrelan earned 250 total points
ID: 33706565
In your php.ini there should be a memory_limit setting. If you don't know where php.ini is on your system you can call phpinfo() which will tell you. You will need to restart IIS after modifying this.

Some servers allow you to dynamically set this value by called ini_set('memory_limit', '3G'); but you'll have to call phpinfo() again after that setting to see if it worked
0
 
LVL 12

Expert Comment

by:Rok-Kralj
ID: 33708177
Just set the memory limit to 3GB or higher (or to anything like 90% of available RAM on the server), as I said. It is fine to use a lot of ram on rare situations (like you said "That will not happen for a while").
0
 
LVL 3

Accepted Solution

by:
bigjdve earned 0 total points
ID: 33886534
By creating indexes, it is able to process the query within the set time limit.
0
 
LVL 12

Expert Comment

by:Rok-Kralj
ID: 33892268
I object.

Reason: Author did not respond to my additional comment. After one month, he posts a "solution", which is a clear effort to get the points back in unfair manner.

As we can read, the problem was in server "memory limit", and after magically the problem becomes "time limit". Important difference.

Proposal: Accept #33696903
0
 
LVL 10

Expert Comment

by:mstrelan
ID: 33892332
I propose accept #33706565 because it explains how to do it, but give equal points to #33696903 as it tells you what the solution is.

I also think the real solution is #33698079. Why would you need every record in memory at one time?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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 …

740 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