Fixing "Fatal Error: Allowed memory size of xxxxxxxx bytes exhausted..."

Status
Not open for further replies.

iFlames

Active Member
1,001
2009
18
0
Error: (Just an example. File name, memory size, etc. can vary)

Code:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 71 bytes) in /home/xxxxxxxx/public_html/search.php on line 1155

How to fix it:

1. On a shared server
Open your .htaccess file and enter this line into it
Code:
php_value memory_limit 32M

Contact Your Host If This Doesn't Work

2. On a VPS/Dedicated server

First step for this is to locate your php.ini file in the server and to see what is the memory limit (this is shown in the error message). Create a file with the below code and name it something like “test.phpâ€

Code:
<?php phpinfo(); ?>

Upload this file to your site root and point your browser to this file, now it will show the phpinfo of the server, in this you will find “Configuration File (php.ini) Path: /usr/local/lib/php.iniâ€, this is your php.ini location. You can find the memory limit also in this page “memory_limit: 32Mâ€

Then you can use putty, SSH client, login to putty and locate the file php.ini and edit the memory limit.

2u6id0y.jpg


Code:
Log in as root.
Type the following and hit enter: vi /usr/local/lib/php.ini
Now that you’re in vi, hit escape a few times then type the following
and hit enter: /memory_limit
That basically does a “find†in the file you’re editing.
Press the “i†key. This puts you in “insert†mode, which basically
allows you to edit things.
Change the current setting (probably 32M) to 64M (or whatever you want).
Press escape, then type :wq and hit enter. That says “save the file
and quit.â€

After this restart your Apache for the changes to effect. You can do this through WHM.
If you dont have WHM installed then use this command
Code:
/etc/rc.d/init.d/httpd restart
 
6 comments
Nice tutorial m8, here is another solution if u use wordpress :)

Add this line of code in your Wordpress WP-CONFIG.PHP file. Add it before any other values. (My preferred choice)
Code:
define('WP_MEMORY_LIMIT', '64M');

Try to increase it to 64M if 32M seems to be insufficient. These solutions can also be applied to other PHP-based programs and not justWordpress.

Source: Bloggista
 
no this is a stupid fix! This does not fix the problem and only masks it briefly. SOMETIMES this is necessary but you should find out why your scripts are requiring that much memory to run.
 
no this is a stupid fix! This does not fix the problem and only masks it briefly. SOMETIMES this is necessary but you should find out why your scripts are requiring that much memory to run.

if you have an alternative way to fix this then post it here
no point talking shit here mate..
 
Status
Not open for further replies.
Back
Top