Last Updated: December 13, 2014

How To Check and Increase PHP Memory Limit In WordPress

If you are blogger and you use WordPress as blogging platform, there are chances that you will see an error which reads “Fatal Error: Allowed memory size of xxxxxx bytes exhausted” either in your browser or server logs.

Usually, this happens when you install a new plugin, upgrade to the latest WordPress version or do other task.

The reason why you get this error is the insufficient memory allocated to WordPress and to get rid of this error you need to increase PHP memory limit of your WordPress blog.

In this post, I am going to teach you how to check and increase the default memory limit when it gets exhausted.

How To Check PHP Memory Limit?

The most common way to check the memory Limit for PHP scripts is to create a PHP file on your server like view-php-info.php and put the following code in it.

<?php phpinfo(); ?>

After creating this file on your server, simple open it in your browser e.g. . Here you will see a table list containing all configuration info about your current PHP environment (including memory limit).

PHP Memory Limit in WordPress

Another simple way to check the memory limit is to install a WordPress plugin called WP-Memory-Usage.

The plugin not only enables you to check the current memory limit but will also show up the current memory usage and the PHP version you are using in the dashboard and admin footer.

How Much Memory Do I need?

By default, the max memory limit for WordPress core is 32 MB but if you are using too many plugins on your WordPress blog especially the plugins that deals with images such as NEXTGenGallery, you probably need 64MB or more memory.

WordPress Memory Usages Overview

If you are unsure of how much memory you need, make use of WP-Memory-Usage Plugin and look out for the memory usage bar. If you find it RED try to increase the max memory limit until it shows up in BLUE color.

How To Increase PHP Memory Limit For Your WordPress Blog

1. Increase Memory Limit via. php.ini

The most common way to increase memory limit is to edit the file on your server. However, most small shared hosting servers won’t give you access to this file.

But if you have access to this file simply follow these steps:

  • Find the location of php.ini on your server by creating view-php-info.php file as mentioned above.
  • Search for “memory_limit” in php.ini and change its value to 64 M or 128 M. In case, there is no “memory_limit” found, add the following line at the end of – memory_limit = 64M;
  • Save it and restart your Apache server with command line – httpd restart

2. Edit Your .htaccess File

A fresh WordPress Installation won’t have a .htaccess file so you need to create it yourself. In case you already have it for some reason just put the following line in it and save the file.

php_value memory_limit 64M

By adding this line in your .htaccess file the memory limit will now be 64 MB. In case, you want more just replace 64M with 128M and you’re done.

3. Change Memory Limit in wp-config.php

If you don’t have access to and you don’t want to mess with your .htaccess file, then this method would be the best for you.

In this method, you don’t need to create a new file. Just adding the following line in your “wp-config.php” file would increase your PHP Memory Limit to 64 MB.

define('WP_MEMORY_LIMIT', '64M');

Over to you.

Do you know any other ways of increasing PHP memory limit in WordPress?


  1. Wow! Interesting and useful post. I guess 3rd method is better by changing the memory limit in wp-config.php. Thanks for sharing :)

    • I am glad you like this post! Thanks for stopping by and leaving comment.

  2. Hi Tesur,
    Wow! Very very informative post. Though I didn’t face this challenge anytime so far. But I am bookmarking your post because if anybody needs to do this, I think you have a great write-up here.

  3. Sunitha says:

    I love this article and bookmarking the site. As a newbie Editing .htaccess and wp.config.php is easiest way to increase limit. Thanks for sharing useful information.

    • I think no one wants to mess with file and that’s why almost every blogger avoids this method and prefers to edit .htaccess or wp-config.php file.

  4. Learn quite a few new things here Tesur Rajan and the plugin you mention WP-Memory-Usage is simply awesome. I just download it and the good news is that my blog memory bar is blue.

  5. Praveen says:

    Could you please suggest me some sites which provide WP optimisation service?

    • Hi Praveen,

      You will find lots sites and even bloggers who are providing WordPress optimization service, just search for them on Google. You can also use the contact form on this blog and send me details of what you’re looking for. May be I can help you out.

  6. Bibin says:

    How to Change Memory Limit in wp-config.php??

    I don’t know where to put this code; i find out wp-config.php in host but on which line should i put this ‘WP_MEMORY_LIMIT’, ’64M’code?? can you say where it is?? i am not an expert, thats why

    • You have to add “define(‘WP_MEMORY_LIMIT’, ’64M’);” inside the main php tag in your wp-config.php otherwise the change doesn’t take effect.

  7. Tim says:

    Very useful post thanks, helped a lot.

    There is one small syntax error
    ‘ ; ‘ is not valid in the .htaccess, just miss it off

    The ‘ memory_limit ‘ in the readout from ‘ ‘ has two columns ‘Local’ and ‘Master’. It changed the ‘Local’ column to 128M, but the ‘Master’ memory stayed at 64M.
    This did the trick for me though

  8. Deb Skene says:

    I am fairly new to WordPress and have struck this memory limit error too many times and trying to find someone to assist me is almost impossible. That is until your post. Thank you so much I have searched so many so called help files and yours if by far THE BEST!! You are my guru. Well done and please keep putting up help files as we all need you.

    Many thanks


  9. Rafael says:

    Hi I did the changes you say in this article, and when I check my phpinfo it displays my current memory limit at 256MB, but when I run the WP-memory-usage and in the email reports for some CRON jobs it says the memory limit is set to -1MB

    Do you know what it could be?

    Many thanks

    • I don’t know what method you followed to increase the memory limit but if it didn’t worked, may be you should try one of the other two methods.

  10. Ed says:

    Thanks! I had a lot of problems with plugins and white screen in my blog. With this change everything is perfectly working!

    64M changed to 512M


  11. Fauzul says:

    Hello, was looking for a way to increase the PHP limit. Didn’t understand the WordPress codex about lifting the limit but luckily stumbled to your blog.

    All things said, your post helped me change the limit value using the wp-config.php edit method.

  12. Arjun says:

    You sir, are a genius. The 3rd method worked flawlessly (a large plugin choked my site), and your explanation is so clear and easy to follow. Thank you. Site is working great. :)

  13. Rafaqat says:

    I was facing the issue of 500 internal error, and i think by increasing memory limit. i can overcome to this error.
    Thanks for the sharing

  14. Thankx. I’m facing this problem, now working grt for me.

Leave a Reply

Your email address will not be published. Required fields are marked *