How to increase WordPress memory limit

How to increase WordPress memory limit - Best Trick 2022
How to increase WordPress memory limit – Best Trick 2022

Table of Contents

Are you getting a WordPress error that says “Allowed Memory Size Exhausted”? This is one of the most popular WordPress errors. Though it is simple to increase the WordPress memory limit in just a few steps.

In order to increase WordPress memory limit follow these steps:

How to increase WordPress memory limit

1. Go to cPanel > Files section > File manager menu:

2. Navigate to the root folder of your domain (by default, it is public_html for the main domain and addondomain.tld for the addon domains). Select the wp-config.php file and click Edit:

Add the following code right before the /* That’s all, stop editing! Happy blogging. */’ line:

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

3. It is also possible to change WP_MEMORY_LIMIT by going to the wp-includes folder of the installation and editing the default-constants.php file.

increase WordPress memory limit
increase WordPress memory limit
// Define memory limits.
if ( ! defined( 'WP_MEMORY_LIMIT' ) ) {
if ( false === wp_is_ini_value_changeable( 'memory_limit' ) ) {
define( 'WP_MEMORY_LIMIT', $current_limit );
} elseif ( is_multisite() ) {
define( 'WP_MEMORY_LIMIT', '64M' );
} else {
define( 'WP_MEMORY_LIMIT', '40M' );
}
}

if ( ! defined( 'WP_MAX_MEMORY_LIMIT' ) ) {
if ( false === wp_is_ini_value_changeable( 'memory_limit' ) ) {
define( 'WP_MAX_MEMORY_LIMIT', $current_limit );
} elseif ( -1 === $current_limit_int || $current_limit_int > 268435456 /* = 256M */ ) {
define( 'WP_MAX_MEMORY_LIMIT', $current_limit );
} else {
define( 'WP_MAX_MEMORY_LIMIT', '256M' );
}
}
How to increase the WordPress memory limit
How to increase the WordPress memory limit

Change the WordPress memory limit as you want and save it.

Leave a Comment

Your email address will not be published.