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.
Top and Best Premium WordPress Themes For Free
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. 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).
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 limitbut will also show up the current memory usage and the PHP versionyou 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.
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 inBLUE 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.
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.
Over to you.
Do you know any other ways of increasing PHP memory limit in WordPress?