With certain plugins, you may encounter error messages that tell you your PHP memory limit is not high enough. It usually means: you need more!
Like your computer being really slow when you run out of memory, PHP does the same thing, sometimes refusing to work flat out. That’s not so good.
There are several ways of changeing this, and I’ll go through a couple of options here:
Editing your .htaccess File
This is probably the safest and easiest way to adjust your PHP Memory Limit. If you don’t know what a .htaccess file is, have a look at this article.
In a plain text editor, open the file and add the following value:
php_value memory_limit 32M
The default value is set by your server (usually 16MB), and line of code will change it for your current directory. Change it whatever you please (I’d recommend 64 or 128M), but please note that some hosting companies may not allow this.
If you don’t have a .htaccess file, just save a plain text document with the above line, upload it to your root directory, and rename it .htaccess – refresh your browser, and you should be good. If in doubt, clear your browser’s cache – it works wonders at times.
Editing you php.ini File
This of course is only possible if you have access to this file. That’s only the case if you have direct access to your server. Ignore this method if you’re on a shared hosting package.
Open the file and have a look for the following line of code. It’s usually located in the section “Resource Limits”:
memory_limit = 32M ; Maximum amount of memory a script may consume (32MB)
Again change the value to something you’d rather see here. Save the file, reboot your server, and you should be sorted.
How to check if my changes have taken place
Once simple and straightforward way is to check if your plugin is working now, preferrably without that error message.
If you’d like to be more certain, have a look at this very simple WordPress Plugin by Next Gen Gallery creator Alex Rabe: it’s called WP Memory Usage. It’s a friendly little thing that will show you not only your PHP memory limit, but also your current PHP memory usage (as the name suggests).
As always, good luck 😉
What about editing the wp-config file instead. it works too.
Good point, thanks for your input. Here’s how to inncrease your PHP Memory Limit to 64MB via wp-config.php:
define('WP_MEMORY_LIMIT', '64M');
Note that this may not work as it’s talking to PHP rather than Apache.