WordPress

Last Updated: October 9, 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.

Select Code
1
<?php phpinfo(); ?>

After creating this file on your server, simple open it in your browser e.g. www.yourdomainname.com/view-php-info.php . 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 php.in 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 php.in – 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.

Select Code
1
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 php.in 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.

Select Code
1
define('WP_MEMORY_LIMIT', '64M');

Over to you.

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

Article by Tesur Rajan

Hey there, I'm Tesur Rajan owner of BubbleIndia. I write about things related to Blogging, WordPress, SEO and Social Media.

Get It NOW! And Make Super Affiliate Commissions

Enter your email address and get our free ebook on "How to make super affiliate commissions".

Privacy Policy. This information will never be shared.