WordPress memory limits – going beyond 256M

WordPress (currently 3.5.1) limits the memory usage to 32M for single-site installations and 64M for multi-site installations on the front-end. In the back-end it is set to 256M (if possible) by default. This is done in the PHP-code, it means that your current web server setup needs to allow setting php.ini variables from code.

So to increase the amount of memory allowed above 256M you will first need to make sure that PHP-code is allowed to change php.ini settings. In Apache this is typically done by defining the “AllowOverride Options” or “AllowOverride All” in your vhost-file.

However, no matter how much memory you define in php.ini or .htaccess, WordPress will never set a higher value then 256M. Why? Because there are two constants that defines this behavior.

Define the following two constants in wp-config.php to set the amount of memory that WordPress should be allowed to use:

// Front-end
define( 'WP_MEMORY_LIMIT', '512M' );
// Back-end
define( 'WP_MAX_MEMORY_LIMIT', '512M' );

Why do I need more then 256M of RAM? Well, if you are asking that question, you probably should not change this value. But if you, like me, are hitting some memory limits due to long running tasks, you might not have an option but to raise the amount of RAM available to WordPress (PHP).

2 thoughts on “WordPress memory limits – going beyond 256M

  1. define( ‘WP_MAX_MEMORY_LIMIT’, ‘512M’ ); Worked for me running 3.5.1. define( ‘WP_MEMORY_LIMIT’, ‘512M’ ); did not. Thanks for the tip!! Saved loads of time.

Leave a Reply

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