Bobcares

How to fix ‘WordPress Allowed memory size exhausted’ error in websites

by | Dec 29, 2016

In WordPress websites, one of the commonly encountered errors is related to the memory size limit. As WordPress is based on PHP, the maximum memory that can be allotted to WordPress depends on the PHP memory limit in the server.

When enough memory is not available for WordPress, the error that shows in the website or log file would be – “Fatal error: Allowed memory size of XX bytes exhausted (tried to allocate XX bytes) in /directory/filename.php on line XX”.

Based on whether the PHP is configured to display errors or not, the symptoms of this memory error would be either a blank page in your WordPress website or error notices displayed in the log file.

 

WordPress Allowed memory size exhausted

WordPress Memory error

 

The WordPress allowed memory size exhausted error can happen during any of these scenarios:

  1. During initial WordPress install
  2. While trying to install or use a new plugin in WordPress
  3. After migrating the WordPress site to a new server
  4. When there are too many posts or plugins in your WP site
  5. The themes and files in the WordPress site are too bulky

What causes ‘WordPress allowed memory size exhausted’ error?

Every webserver has certain limits set on its memory usage, to avoid a resource abuse. By default, the memory allocated for WordPress is 40 MB for single site and 64 MB for multi-site.

The ‘Allowed memory size exhausted’ error in a WordPress site clearly means that the webserver is running out of its allocated memory limit for PHP.

This can happen due to 2 main reasons:

1. The website contains WordPress plugins or other data that consume more memory than allowed for use by the site.

2. The webserver is configured with a very low memory limit than required for the basic functioning of the WP site.

[ You don’t have to lose your sleep to keep your customers happy. Our Hosting Support Specialists cover your servers and support your customers 24/7 at just $9.99/hour. ]

How to fix the error ‘Allowed memory size exhausted’ for WordPress sites

WordPress websites have a configuration limit that allows to set the maximum memory that can be used for PHP by WordPress. This is set with the parameter ‘WP_MEMORY_LIMIT’ in ‘wp-config.php’.

The file ‘wp-config.php’ is the configuration file for a particular WordPress install and is found in the WordPress root directory. To increase PHP Memory to 128 MB, this setting should be updated with the value of memory limit that you require, say 128 MB:

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

But this limit is further limited by the PHP memory limit for the site. WP_MEMORY_LIMIT cannot exceed a value that is set as PHP ‘memory_limit’ in the ‘php.ini’ file, which is the configuration file for PHP in the server.

How to increase PHP memory size limit

Some webhosts allow users to have custom PHP settings using ‘php.ini’ or ‘.htaccess’ files in their accounts. To increase the PHP memory_limit that is allowed for a particular website, add the following code in the user’s .htaccess file:

php_value memory_limit 128M 

If the user has custom php.ini file, then the entry to be added in it is:

memory_limit = 128M ;

But again, the user limit for memory is limited by the server wide memory_limit setting. To increase the memory limit in the server, edit the server-wide php.ini file and increase the value set for ‘memory_limit’.

memory_limit = 128M ;

After making the changes for the PHP memory limit, the new setting can be verified using a ‘phpinfo’ file in the website, which will show both server wide and domain specific memory limits.

 

WordPress Allowed memory size exhausted - PHP memory limit

PHP memory limit

[ Use your time to build your business. We’ll take care of your customers. Hire Our Hosting Support Specialists at $9.99/hr. ]

Points to note..

Today we saw how to resolve WordPress allowed memory size error by increasing the memory limit for WordPress and PHP, but increasing this limit should be done with utmost caution.

Unnecessarily increasing the memory limit to a very high value can cause PHP applications to abuse the resources and crash the web server. Also, caution has to be exercised while installing themes and plugins into the WordPress site.

Heavily customized and loaded themes can use up all the available memory. Many custom WordPress plugins come with unoptimized code, which can abuse the memory in the server.

Using the option ‘WP_MAX_MEMORY_LIMIT‘, it is advisable to set a maximum limit of memory that can be used by WordPress so that the plugins do not abuse the memory.

At Bobcares, we audit the WordPress plugins installed by websites and customize them to avoid the server resources getting affected, especially in a shared hosting environment.

Our 24/7 monitoring team keeps a tab on the memory usage of servers and resolve any issues promptly. If you’d like to know how to efficiently manage your WordPress hosting servers, we’d be happy to talk to you.

STOP SPENDING TIME ON SUPPORT!

Do you spend all day answering technical support queries?

Wish you had more time to focus on your business? Let us help you.

We free up your time by taking care of your customers and servers. Our engineers monitor your servers 24/7, and support your customers over help desk, live chat and phone.

HIRE SUPPORT SPECIALISTS AT $9.99/HR

Bobcares provides Outsourced Web Hosting Support and Outsourced Server Management for online businesses. Our services include 24/7 server support, help desk support, live chat support and phone support.

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.