How can I fix a PHP fatal “out of memory” error?

If your PHP configuration is limited to less than 128mb of memory, you may get a PHP fatal “out of memory” error when WordPress attempts to resize an image, etc. 32mb and 64mb memory limits were common a few years back, and some hosting providers have not revised their PHP configurations since then — which can cause problems with the latest versions of WordPress and some common plugins.

Increasing the WordPress Memory Limit

  1. Edit your wp-config.php file and enter something like:
    define('WP_MEMORY_LIMIT', '128M');

    See Increasing memory allocated to PHP in the WordPress codex for more info.

  2. If you have access to your PHP.ini file, change the line in PHP.ini:
    memory_limit = 128M ; Maximum amount of memory a script may consume (128MB)
  3. If you don’t have access to PHP.ini try adding this to an .htaccess file:
    php_value memory_limit 128M

Leave a Review