Fatal Error: Allowed Memory Size in WordPress is Exhausted

WordPress can often run into memory issues with the web server. The WordPress Core team is constantly working on lowering memory footprints though.

There are a few reasons why you may be running into memory issues with WordPress, let’s dive into them below and discuss some potential solutions for you.

Example Errors

Here are some example errors you may be seeing.

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 1853353 bytes) in /home/imag5621/public_html/yanikphotoschool/wp-includes/http.php on line 1027

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 143 bytes) in /home/www/web238/html/blog/wp-admin/admin-functions.php on line 1618

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 19456 bytes) in wp-admin/includes/theme.php on line 81

Exhausted Memory Solutions

There are a number of things we’re going to review that may work for you.

1. Raise the memory limit for PHP in your wp-config.php file:

define('WP_MEMORY_LIMIT', '64M');
Or…
ini_set("memory_limit","64M");

2. If you have access to your server’s php.ini file, try adjusting the memory_limit value.

memory_limit = 64M;

3. If you don’t have access to your server’s php.ini file, try adjusting the memory limit inside your .htaccess file.

php_value memory_limit 64M

One of these solutions will generally fix your WordPress memory issues.

One thing to make sure is that you are running some sort of caching plugin. We recommend and use W3 Total Cache here on WPForce.com, and we feel it’s the most effective. We use Apache, FastCGI, APC, and Memcached for all of the caching.

Comments

  1. By Pete on

    This is what my host told me some time ago…
    For the cPanel hosting to enable higher memory you will need to do the following.

    1. create a php.ini file with the below code in it in the root:
    memory_limit = 256M
    2. Enter the below line into the .htaccess file
    SetEnv PHPRC /home/[cpanel-username]/public_html/php.ini

    Once you have done these steps the error will no longer come up.

    And this to disable safe mode…
    Hi

    You can switch off PHP safe mode within your own hosting account. First,
    create a plain-text file called .htaccess which is to be stored in your
    hosting account’s public_html directory.

    Inside this file, you should have the script:
    suPHP_ConfigPath /home/’username’/

    Where ‘username’ represents your hosting account username.

    Next create a plaintext file called php.ini (which should be located in
    your root directory when you login to FTP ie: /home/’username’/)

    In this file you must have the following line:

    safe_mode = off

    You can refer to the following website for more information on safemode.
    [http://www.php.net/features.safe-mode|http://www.php.net/features.safe-mode]

    Reply »

    • By Jonathan Dingman on

      Certainly some good tips, thanks Pete!

      I personally wouldn’t encourage setting the memory_limit to 256M as that could cause some instability of a server, especially if you’re running a VPS or cloud hosting. When you’re limited on memory to say, 2gb or 3gb, you don’t want each PHP process taking up 5-10% of your memory.

      Reply »

  2. By Pete on

    I didn’t know that. I emailed my host and he told me this… thanks.

    Reply »

  3. By on

    The php.ini was the one that worked for me. editing the WP file didn’t work for some strange reason. But these are the best and only solutions that work so nice work.

    Reply »

Leave a Reply

Your email address will not be published. Required fields are marked *