Increase WordPress and PHP Memory Limit

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.
WordPress 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 blog.
To increase the default WordPress memory add the following line to the wp-config.php file:
define(’WP_MEMORY_LIMIT’, ’64M’);
Keep in mind the above limit is 64MB, but it can be set at any increment of 8MB. For instance, 32MB, 40MB, 64MB, 128MB.
The wp-config.php is located in the root directory of your WordPress installation. If you are on a shared hosting platform you may need to ask your host to increase the memory limit. On a self hosted platform you can increase the memory as long as it does not exceed the amount of RAM installed on the server.
After increasing the memory limit for WordPress you will need to also increase the PHP memory limit. If your WordPress installation is self hosted, but your have more than one WordPress blog installed, you will need to allocate enough memory to handle all the installations.
On Linux servers the PHP file that requires editing is located at:
/etc/php.ini
In the php.ini file find the following line:
memory_limit =
Set the memory limit to match your installation. Since we set the limit for WordPress in the above example to 64MB we will do the same for PHP’s memory limit:
memory_limit = 64M
If I had two blogs using 64MB each I might set PHP higher:
memory_limit = 128M
Having enough memory allocated for your WordPress installation can prevent a lot of out-of-memory issues.
The TPC! Memory Usage plugin can help keep track of your WordPress and PHP memory usage and see their limits at a glance.
12 comments on “Increase WordPress and PHP Memory Limit”
Leave a Reply
© Copyright Nerd Grind 2009 - 2010. All rights reserved.

As an FYI, the code that you are saying to use is incorrect… it should not include the “B” in “MB”
It should read:
define(‘WP_MEMORY_LIMIT’, ’64M’);
Nice plugin though ;)
Thanks for catching that.
Hi There,
I have some problems with the WP Plugin XML-Sitemap Generator…
Practically when i try to make the Sitemap it says “The last run didn’t finish! Maybe you can raise the memory or time limit for PHP scripts”
I’ve raised my memory limit to 64 (from 32) but nothing happens… same problem… can you tell me why?
Yes. I used the plugin you mentioned years ago, but it couldn’t handle a blog of mine that had more than 2,000 posts, because that script is a huge memory hog. To solve this problem I wrote my own solution many years ago. I will be publishing my script later this year, which can handle any number of posts without increasing the script memory limit.
I’m getting memmory errors everytime I switch pages in my wordpress now. I just upgraded to a VPS and did everything it says here. But nothing. IS it because I might have uploaded everything in binary mode by accident? I have a few plugins that needed to be uploaded in binary and I didn’t switch it back I don’t think.
Everything should always be uploaded in binary, which will avoid any and all upload issues. The memory errors could be a bad line of code in one of your plugins. Disable all plugins, then enable them one at a time until you find the plugin causing the problem.
Nice post, but there is a hardcoded memory limit in wordpress that prevents you to raise the limit above 256MB for the admin.
Official memory requirements for single-site WP is 32M (48M)
Official memory requirements for multi-site WP is 64M (unofficial 256M)
http://wordpress.org/support/topic/wp3-exeed-256-memory-limit
http://wordpress.org/extend/plugins/memory-bump/
I installed the TPC! Memory Usage plugin you recommend, and it’s great I can see that it’s the PHP memory limit I need to increase. I don’t have access to php.ini, so I used the .htaccess method as you described. According to the plugin though the PHP memory limit has not been increased. I also used the technique you describe to increase the WP memory limit in wp-config.php, but again according to the plugin there has been no change in wordpress memory usage.
What could be causing this? I don’t have any caching plugins installed because the site is still under development.
You mentioned you were writing a last year, is it finished? Do you have a link to it?
If you don’t have access to the php.ini on a shared hosting environment, then you’ll need to ask your host to increase the PHP memory for your WordPress blog.
WordPress ‘Fatal Memory Error’ workaround:
Try this:
1. Deactivate all plug ins.
2. Upgrade wordpress just click ‘upgrade automatically’)
3. Reactivate plug ins.
Worked for me.
Hi guys… had a major breakdown over this one. Tried everything to no success. TCP memory plugin still showed wordpress at 32M but finally changed the default constants.php in wp-includes and it increased the wordpress figure in TCP. Lets see hey!