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
technofreak
Forum Commoner
Posts: 74 Joined: Thu Jun 01, 2006 12:30 am
Location: Chennai, India
Contact:
Post
by technofreak » Wed Jun 21, 2006 11:19 pm
Hi,
when i try to open my file login.php in the browser using the url "http;//localhost/login.php" the following fatal error gets displayed. what to do ?
Code: Select all
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 8192 bytes) in /var/www/login.php on line 1
How do i allocate more memory. Earlier everything was working fine with my previous files
Last edited by
technofreak on Wed Jun 21, 2006 11:47 pm, edited 1 time in total.
olegkikin
Forum Newbie
Posts: 12 Joined: Wed Jun 21, 2006 10:01 pm
Post
by olegkikin » Wed Jun 21, 2006 11:21 pm
8388608 is probably the limit set by your server. Change it.
technofreak
Forum Commoner
Posts: 74 Joined: Thu Jun 01, 2006 12:30 am
Location: Chennai, India
Contact:
Post
by technofreak » Wed Jun 21, 2006 11:27 pm
My php.ini file shows this
Code: Select all
memory_limit = 8M ; Maximum amount of memory a script may consume (8MB)
my login.php file is 294bytes and there are totally 4 files of similar size. Why does then such an error occurs when I have 8MB of size allocated for the script ?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Jun 21, 2006 11:30 pm
that's 8MB of memory for the script and all it's variables, including those that come from a database, files, external pages, etc etc.
Benjamin
Site Administrator
Posts: 6935 Joined: Sun May 19, 2002 10:24 pm
Post
by Benjamin » Wed Jun 21, 2006 11:31 pm
Are there any for or while loops in it? Post the login.php code.
Benjamin
Site Administrator
Posts: 6935 Joined: Sun May 19, 2002 10:24 pm
Post
by Benjamin » Wed Jun 21, 2006 11:32 pm
feyd wrote: that's 8MB of memory for the script and all it's variables, including those that come from a database, files, external pages, etc etc.
Maybe your loading the entire database into memory?
technofreak
Forum Commoner
Posts: 74 Joined: Thu Jun 01, 2006 12:30 am
Location: Chennai, India
Contact:
Post
by technofreak » Wed Jun 21, 2006 11:35 pm
Here is my login.php
Code: Select all
<?php
session_start();
include("login.php");
page_header("login.php", "tenmiles.gif", "TenMiles Corporation", "Login Page");
include("navig.php"); ?>
<div><table>
<tr><td>
<?php include("login_script.php"); ?>
</td></tr>
</table></div>
<?php
include("footer.php");
page_footer("");
?>
The size of include files are ... header.php --> 250 Bytes, footer.php --> 201 Bytes and login_script.php --> 2.5 KB.
It doesnot contain any loops, it has one mysql query for the login verification of username and passowrd.
Benjamin
Site Administrator
Posts: 6935 Joined: Sun May 19, 2002 10:24 pm
Post
by Benjamin » Wed Jun 21, 2006 11:39 pm
That is your problem, the file is including itself, hence a loop.
technofreak
Forum Commoner
Posts: 74 Joined: Thu Jun 01, 2006 12:30 am
Location: Chennai, India
Contact:
Post
by technofreak » Wed Jun 21, 2006 11:39 pm
My code will fetch data from the databse only if the form being displayed is filled up and the submit button is filled. This error is shown before the form being displayed. So, it can't be a problem of database ? Also, only one row of data is got from the databse, will it occupy 8MB of space.
My previous codes where much bigger than this, and it was working fine with it.
olegkikin
Forum Newbie
Posts: 12 Joined: Wed Jun 21, 2006 10:01 pm
Post
by olegkikin » Wed Jun 21, 2006 11:39 pm
It's not the size of your PHP files. It's how much memory they use. PHP is very greedy with memory. I had scripts that used 5 GB (not MB) of RAM. (I had to rewrite them in C++ actually, because it was getting crazy).
and remove this, it's an infinite loop
include("login.php");
technofreak
Forum Commoner
Posts: 74 Joined: Thu Jun 01, 2006 12:30 am
Location: Chennai, India
Contact:
Post
by technofreak » Wed Jun 21, 2006 11:41 pm
astions wrote:
That is your problem, the file is including itself, hence a loop.
thanks a lot, such a silly mistake... proly i have to increase the sharpness of my vision much more
its "header.php' instead