Troubleshooting for PHP Allowed memory size

Have you ever get an error warning displays one of these messages? Is your WordPress too slow and run out of memory?

PHP Memory Limit

Fatal error: Allowed memory size of 8388608 bytes exhausted.

or

PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 6233929 bytes) in /home/…/press/wp-includes/cache.php on line 330

or

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 368640 bytes) in /wordpress/wp-includes/class-simplepie.php on line 9575

WordPress is a collection of PHP script files, so it only makes sense to increase the PHP memory limit when the WordPress memory limit is increased. It comes with a default memory limit of 32MB, but this may not be sufficient when you have a lot of plugins and a lot of traffic to your site.

If you get one of those messages we mentioned, meaning you need to increase your WordPress memory limit, which can be done very easily in two ways. Choose which one you prefer.

#1. Using WordPress Plugins

Using plugins could save your work and time. Here are two useful plugins that let you monitor and know your WordPress’s current memory usage.

WP Memory Usage

PHP Memory Limit

Simple and light, displays your PHP version, memory limit and current memory usage in the dashboard and admin footer.

TPC Memory Usage

PHP Memory Limit

This one is more advanced with more comprehensive report. This plugin can help keep track of your WordPress and PHP memory usage and see their limits at a glance. As of version 0.4, administrators have the ability to view detailed system information about their web server, MySQL, PHP, and WordPress software. Requires PHP5.

#2. Modifying Your WP Config

This way is so simple it takes not more than a minute. Simply open your wp-config file which located at the root of your WordPress install, and paste the following code in it.

[php]define(‘WP_MEMORY_LIMIT’, ‘XXX’);[/php]

XXX is the desired MB limit like 64MB, 80MB, etc, at any increment of 8MB. By default it should be 32MB. Example:

[php]define(‘WP_MEMORY_LIMIT’, ’64M’);[/php]

Once saved, WordPress will be able to use as much memory as specified. Done.

If you still get the error after this fix, then please contact your host. We hope these tips will help you fixing frustrating memory issues. Let us know in the comments if you got any questions or useful tips.