By Janis Miciopulos on Wednesday, 01 June 2016
Category: WordPress Tips & Tricks

Wordpress memory limits

We often receive clients requests to increase the PHP memory limits  on WordPress instances. The error message they receiving is: “Allowed memory size of xxxxxx bytes exhausted" or the information in the Dashboard:

By default this limit on our platform is set to 512MB. You can verify this by running a simple PHP script. Just create a file info.php in a root directory of your website (if you happen to have the website on CloudAccess the proper directory is: httpdocs) and put there:

<?php
phpinfo();
?>

You will be able to run it later, by going to: yoursitename.com/info.php and searching the option ‘memory limit’ as it is shown below:

Since version 2.5 WordPress has got new WP_MEMORY_LIMIT variable. So, by default the limit is set to 40MB (and 64MB when it comes to multisite).
This limit is coded in a file: default-constants.php in a wp-includes directory.

In most cases you don’t want to worry about it, however, it happens sometimes, that WordPress plugins disregard memory_limit set on our platform and blindly take WP_MEMORY_LIMIT that is set by wp-includes/default-constants.php (40MB). In this case you would need to do two things:

1) Add these two lines to the top of wp-config.php (a file in the root -httpdocs directory), right after "<?php":
define('WP_MEMORY_LIMIT', '256M');
define('WP_MAX_MEMORY_LIMIT', '512M');

2) Change lines 22-26 of wp-includes/default-constants.php to the following snippet:
if ( is_multisite() ) {
define('WP_MEMORY_LIMIT', '256M');
}
else {
define('WP_MEMORY_LIMIT', '256M');
}

If you happen to have this problem and you are our client, we will be more than happy to sort out this problem for you. All you need to do is: submit a support ticket

Leave Comments