Error PHP Fatal error: Out of memory (allocated 24641536) (tried to allocate 24381441 bytes) on cPanel server with php scripts


Today came across with the memory exhausted error and while investigation note that after increasing the memory in server php.ini file even though increased php memory limit for the particular user as server is suphp enabled, but did not help…šŸ˜¦šŸ˜¦

While browsing the site I find the error as below under error logs ::
==========================================
[root@server/home/username/public_html]# tail -f error_log
[01-May-2012 20:45:55] PHP Fatal error:Ā  Out of memory (allocated 24641536) (tried to allocate 24381441 bytes) in /home/username/public_html/filename.php on line 117
==========================================

——————————————————
Soution 1 ::

1. If server is suphp enabled then do as below ::

>> create Or copy server php.ini under public_html as below :

#cp /usr/local/lib/php.ini /home/username/public_html

Then open the php.ini file

# viĀ  /home/username/public_html/php.ini

Find for the memory_limit parameter and change the value as below :

memory_limit = 32 MB

To

memory_limit = 64 MB

Save the file.

>> Now open the .htaccess file under your public_html

#vi /home/username/public_html/.htaccess

and enter the code below :

suPHP_ConfigPath /home/username/public_html

Save the file.

2. Now try to access your page again and check if that help to resolve the issue.
——————————————————

In my case solution 1 did not help and then I checked the issue further and came to know that the issue was with the apache memory limit. I did check as below :

——————————————————
Solutions 2::

1. Checked the parameter RLimitMEMĀ  under apache configuration file.

# vi /etc/httpd/conf/httpd.conf

Find for RLimitMEM

you will see something like below :

RLimitMEM 154857600 154857600
RLimitCPU 150 200
RLimitNPROC 25 30

Just increase the value of RLimitMEM , In my case I did as below ::

RLimitMEM 184857600 184857600

NOTE :: if you don’t find the value in httpd.conf, please do check in the file /etc/httpd/conf/includes/pre_main_global.conf

and then restart apache on the server.

# service httpd restart
——————————————————

and now try to access your site. your site will work like a charm without any error.

One Response to “Error PHP Fatal error: Out of memory (allocated 24641536) (tried to allocate 24381441 bytes) on cPanel server with php scripts”

  1. I just spent two days trying to find a solution to this error that happened on 12 of my wordpress sites, trying out various so-called solutions and without much help from my server support, thank you so much, your SOLUTION 2 worked a dream for me. Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: