Firstly, sorry for the click-baity title, but I do believe that this tip has the potential to change your WordPress experience for the better and it’s something that doesn’t seem to get talked about a lot by people recommending things to increase your page speed.
define( 'WP_MEMORY_LIMIT', 'xxxM' );to your wp-config.php file and that’s it! You just need to replace
xxxMwith whatever amount of memory you choose to use.
How much memory do I need?This is a tricky question to answer as no two WordPress Themes seem to be the same but bascially, the more you can give it, the better. The general consensus seems to be 256M is the highest you should need to go and most themes ask for somewhere between 64M and 128M so that they run properly. You might want to go higher so that you can safely run plugins on top of the theme but most installs I have seen seem to run around 80M with a decent number of plugins installed.
How do I see how much memory I have allocated?Good question! There are a few ways to do it but the easiest I’ve found is by adding a plugin like Server IP & Memory Display. I like this one as it’s really lightweight and adds a small sentence of code to the bottom of certain pages to show you what your server details are, how much memory is allocated and how much you are using and also what php version you are running. As you can see, the limit that is showing here is way below the recommended amount and so we need to add the code to the wp-config.php file to increase this. The easiest way to do this is to use an FTP program like Filezilla or Cyberduck to pull your file from the server. Then add the define code I showed you above to the bottom of the file, just above “/* That’s all, stop editing! Happy blogging. */” Now you have a site that’s getting as much memory as it can handle and you should notice an increase in your speed. If you don’t, then it’s likely that your site was not that big to begin with and didn’t need that much memory to run. If you don’t think that that is the case, then you can try the following.
Alternate ways of increasing WordPress memoryNow if you can’t get your memory limit to increase this way, you may need to have a chat with your hosting provider as they might have restricted control of this particular part of the WordPress program so that they can make sure people don’t go crazy with their memory allocation or some such thing. Also there are other ways to do it including:
Editing your php.ini file.If you have access to this file (and you may not depending on whether your hosting company allows this), you can add the following code:
memory_limit = 256M ; Maximum amount of memory a script may consume (64MB)
Editing your .htaccess fileAgain, if you have access to this file, then you can add the following code:
php_value memory_limit 256M