Increase PHP Memory Limit to avoid WordPress crashing
WordPress is so common that most shared web hosting accounts as well as dedicated hosting accounts are optimized to be able to run it with no issues. However if you have a large number of plugins or you need to upload large files to WordPress there may be times when you need to increase the amount of memory that WordPress can use.
Why to increase WordPress PHP memory?
Increasing your WordPress PHP memory limit can be the solution to several problems, like memory exhaustion, white screen of death, HTTP error when trying to upload images and of course improve the speed of the website.
From time to time you have your WordPress mysteriously crashing. The reason of crashing is that WordPress has not received enough memory. WordPress uses a certain amount of memory on your server just like any program consume memory from the PC. So its important to increase PHP Memory Limit to avoid WordPress crashing.
Increase WordPress memory by Editing wp-config.php file
The wp-config.php file is an important file in your WordPress installation located in the root of your WordPress file directory. and contains your website’s base configuration details, such as database connection information.
When you first download WordPress, the wp-config.php file isn’t included. The WordPress setup process will create a wp-config.php file for you based on the information you provide.
The WP_MEMORY_LIMIT option allows you to specify the maximum amount of memory that can be consumed by PHP. This setting may be necessary in the event you receive a message such as “Allowed memory size of xxxxxx bytes exhausted”.
By default, WordPress will attempt to increase memory allocated to PHP to 40MB for single site and 64MB for multisite, so the setting in wp-config.php should reflect something higher than 40MB or 64MB depending on your setup.
WordPress will automatically check if PHP has been allocated less memory than the entered value before utilizing this function. For example, if PHP has been allocated 64MB, there is no need to set this value to 64M as WordPress will automatically use all 64MB if need be.
If your host does not allow for increasing the PHP memory limit–in that event, contact your host to increase the PHP memory limit. Also, note that many hosts set the PHP limit at 8MB.
So let’s assume that your current memory allocation is 40 MB with it not being a multisite installation. We want to increase this limit to say 96 MB. To do this, open up your wp-config.php file in your WordPress root directory, and copy and paste the following line:
define( ‘WP_MEMORY_LIMIT’, ’64M’ );
The code will look like this:
// Increase the memory limit for PHP from within WordPress
define( ‘WP_MEMORY_LIMIT’, ’64M’ );
// ** MySQL settings – You can get this info from your web host
/* The name of the database for WordPress */
When in the administration area, the memory can be increased or decreased from the WP_MEMORY_LIMIT by defining WP_MAX_MEMORY_LIMIT.
So lets look at the basic steps for increasing the WordPress PHP limit
1. The first step is to download the wp-config.php file.
To do this you need to use an FTP client, login to the ROOT of your website in the public_html folder where WordPress has installed.
Download the wp-config.php file to your computer.
2. Edit the wp-config.php file.
Open the file in Dreamweaver or other text editor like Notepad. DON’T use Word Pad. It might change the file format that will make it unreadable.
Decide the memory limit you want which could be 64 MB, 94 MB and 128 MB.
Copy the code
Should be at the top of the define list in WordPress
Above this code you can add a code comment
/** Increase default PHP memory to 64 MB*/
Once you have inserted it, save the file under new name as wp-config-new1.php. Then use the FTP client to upload it back to your website. After uploading the file to your new server rename the existing wp-config.php to wp-config-old1.php. Rename the new file you just uploaded to wp-config.php. It’s important that you don’t delete the old file and keep a backup in WordPress just in case something goes wrong. When you are done log out from your FTP program and check your website is OK.
Now assuming that everything is OK and your WordPress website is running, you need to know if the memory limits have been increased. The best way to do that is to use a plugin from WordPress main site. Install a plugin Server-ip-memory-usage to monitor the WordPress memory and PHP. This plugin displays the total memory, used memory, percentage of used memory, the IP address and the PHP version in the admin footer.
What can Server-ip-memory-usage display in WordPress?
This plugin displays the following:
Percentage of used memory
PHP version in the admin footer
Latest posts by Christine (see all)
- Top Affiliate Friendly Paid Traffic Sources for your Online Business 2017 - June 18, 2017
- Recommended 15 Free WordPress Plugins for Successful Blogging - December 18, 2016
- Why are Contextual Links Important For WordPress SEO - October 16, 2016