wp_memory_limit wordpress

wp_memory_limit wordpress

There may be times when you receive an error such as this:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 122880 bytes) in /myphpfile.php on line 127

If you run woocommerce (like me), you may get a message in your woocommerce system status saying that you should increase your memory limit.

There is an easy way to change this.

  1. First find your wp-includes/default-constants.php file.
  2. Line 18 should begin with a comment, “// set memory limits”
  3. It will look something like this:
    1. // set memory limits
      if ( !defined(‘WP_MEMORY_LIMIT’) ) {
      if( is_multisite() ) {
      define(‘WP_MEMORY_LIMIT’, ’64M’);
      } else {
      define(‘WP_MEMORY_LIMIT’, ’40M’);
      }
      }
  4. My woocommerce system status mentioned that I should increase from 40M to 64M
  5. I chose to increase to 128M just to be sure I don’t run into any future problems
  6. My file looked like this:
    1. // set memory limits
      if ( !defined(‘WP_MEMORY_LIMIT’) ) {
      if( is_multisite() ) {
      define(‘WP_MEMORY_LIMIT’, ’64M’);
      } else {
      define(‘WP_MEMORY_LIMIT’, ‘128M’);
      }
      }
  7. Thats it!

There are no comments published yet.

Leave a Comment