How to increase your PHP Memory Limit

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 ;-)

Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or drawing on tablet devices. He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.