Connect with us

Wordpress Tips

How to Fix: Memory Issue: Fatal error: Allowed Memory Size Of

WordPress has been very good to us. We have never had major issues running it on all our servers. But once in a while things just don’t quite work. One of those times, we were getting this message every time we tried to post a new article or update existing ones: “Memory Issue: Fatal error: Allowed memory size of 268435456 bytes exhausted.” We are on a dedicated server with plenty of RAM and a powerful processor. The easiest way to handle this is to increase the memory limit. But if you have unoptimized code that cause memory leak and other issues, temporary fixes won’t do. Here are a few ways you can go about fixing issues like this:

Remove and track the performance of your plugins: the first thing I usually do when things go wrong is deactivate all plugins and keep testing. You could always use a plugin performance monitor to get a better idea which ones may be causing your site issues (e.g. similar post plugins).

Optimize your database: our problem went away after I optimized my database. That may or may not work for you. You can optimize your database using a plugin or by logging into phpMyAdmin.

cpanel

Configure PHP using your WebHost Manager: this does not work for everyone. But on a dedicated server like ours, we could simply log into cPanel, go to PHP Configuration Editor, and change the memory limit.

Change your php.ini or .htaccess file: if you have access to this file on your server, you could just edit it and change the line ‘memory_limit’ to something you are comfortable with (e.g. memory_limit = 512M). Don’t have access to that file? This might work: php_value memory_limit 128M. You have to add it to your .htaccess file.

phpini

Define memory limit in your wp-config.php file: this approach is worth pursuing if you don’t have access to your php.ini or for some reason can’t edit your site’s .htaccess file. Just add this line to your configuration file: define(‘WP_MEMORY_LIMIT’, ‘512M’)

Keep in mind that your job is not done unless you figure out what is causing these issues. You have to check your plugins, server configurations, and anything else that could be responsible. Problems like this could come back to bite you where it hurts down the road unless you permanently fix them.

Continue Reading
You may want to check out:
*some of our articles and lists include affiliate links to fund our operations (e.g. Amazon, Elegant Themes, Envato). Please read our disclaimer on how we fund Exxponent.
Click to comment

More in Wordpress Tips

To Top