As you know, we developed the Image Store plugin and many photographers using the plugin with large image files will come across “Out of memory” errors when processing these large images.
If you ever received this error in WordPress there are two settings (constants) that you can use in the wp-config.php file to control the memory limits, WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT. The question is, what is the difference between these two and which you should use?
WP_MEMORY_LIMIT
This is the default memory that WordPress should use when it is running any process; visiting a page, saving a post, editing a category, and for the most part is lower than WP_MAX_MEMORY_LIMIT
define( 'WP_MEMORY_LIMIT', '128M' );
WP_MAX_MEMORY_LIMIT
This constant is used by WordPress when a process may need more memory; compressing or uncompressing zip files, editing and creating images, uploading files, and for the most part higher than WP_MEMORY_LIMIT
For the Image Store plugin be sure to use WP_MAX_MEMORY_LIMIT, it is used in the generation of images in the wp_generate_attachment_metadata function.
define( 'WP_MAX_MEMORY_LIMIT', '528M' );
Known issues
Some servers have the “suhosin” PHP extension installed and it will not allow PHP to modify the memory limit beyond the configured memory limit. To increase the limit you will need to change the php.init file.
Another option is to increase the memory using .htaccess
php_value memory_limit "16M"
the same restriction applies if suhosin is installed and some server will return an error.
Comments
One response to “WordPress out of memory error”
Very nice, thank you