WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT – How to increase memory limit in WordPress?

Dear WordPress users today we will check the WP_MEMORY_LIMIT and the WP_MAX_MEMORY_LIMIT, then we will check how to increase memory limit in WordPress. A lot of WordPress users need to increase memory limit for their websites for different reasons, so today we will show how to configure it. Also, we will check what’s the difference between WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT.

As we know, by default, WordPress has a memory limit of about 40 MB. This limit applies to the single PHP script, so this limitation will not allow us to use more than 40 MB of RAM. Reasons for increasing the memory are different, but the main reason can be the running of a heavier plugin(for example bbPress or WooCommerce).

  • WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT
  • The Difference Between WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT
  • How to increase memory limit in WordPress?
  • WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT

    Let’s understand what is the WP_MEMORY_LIMIT. It is a WordPress setting, that allows you to limit the memory used by PHP scripts on your website. You can set any value you need for these settings, but we will recommend to set it as lower as it’s possible because if you set a higher limit(for example 512 MB) it can overload your server memory. Let’s check an example of WP_MEMORY_LIMIT setting (also, check this nice WordPress YouTube plugin).

    This setting will set a memory limit for PHP script to 256 MB.

    Also, there is another setting – WP_MAX_MEMORY_LIMIT. This setting will set a limit for admin PHP scripts. Let’s check an example (also, check our WordPress Countdown plugin).

    This setting of WP_MAX_MEMORY_LIMIT will set a memory limit for PHP script to 256 MB only for the admin PHP scripts.

    The Difference Between WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT

    Now let’s check the difference between WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT. As we already said, WP_MEMORY_LIMIT responsible for the general memory limit of PHP scripts, while WP_MAX_MEMORY_LIMIT responsible for the admin panel scripts limit. Many users use these two settings together and set different values for these settings. Let’s check an example again (also, you can check our WordPress Pricing table plugin).

    As you can see, now we have different values for these two settings. Using this setting, we will get a 64 MB limit for the front-end scripts memory and 256 MB limit for the admin part.

    How to increase memory limit in WordPress?

    First of all, we should mention that your WordPress memory can’t be bigger than the PHP memory, so first you need to check the PHP memory and than try to increase the WordPress memory limit. You can change the PHP limit from the php.ini file. Usually, this file located in the main folder of your hosting, so you can easily find it. If you can’t find this file, then you can ask your hosting support, they will tell the location. For example, find such code in php.ini file – “memory_limit 512M” and then change the value (also, check this useful tutorial – What is PHP.INI?).

    Now let’s check how to increase memory limit in WordPress:

    1. First of all, open your WordPress folder and find from there the wp-config.php file. Usually, wp-config.php located in the main folder of your WordPress.
    2. Edit the wp-config.php file. Go to the end of the wp-config.php file.
    3. Then add this code to the end of wp-config.php file – define(‘WP_MEMORY_LIMIT’, ‘256M’);. This setting will increase the memory limit of your WordPress website.
    4. Now just save the wp-config.php file. That’s all (also, you may like to check the Best WordPress Shortcode Plugins list).

    How to increase memory limit in WordPress? – Video Tutorial

    Leave a comment