memory_error

Lazyest Gallery memory check

Some of you have noticed that exclamation mark images started to appear in the gallery. This is because of Lazyest Gallery 1.0 checks the available memory before trying to create a thumbnail or slide image. If the amount of memory available to PHP is not sufficient, Lazyest Gallery will output this warning image.

What happens?

In previous versions, the resizing functions just tried to increase the memory buffer without any checking. If the memory buffer was increased, the resized images would be created without problems. If not, it depended on your server php memory settings. Most servers could still resize the images, but some would crash issuing a fatal error message like:
Fatal error: Allowed memory size of 138412032 bytes exhausted (tried to allocate 4096 bytes) in /home/myserver/public_html/wp-content/plugins/lazyest-gallery/inc/image.php on line 134

Lazyest Gallery 1.0 will not crash anymore, the exclamation mark image will alert you to increase the memory available to php.

How much Memory?

The amount of memory needed, depends on the size of your images in pixels. The size in kB is irrelevant. The GD image engine in PHP will map the entire image in full color in memory. Most servers allocate maximum 16M for PHP. It doesn't take much to reach 16M, for example, consider a "lowly" 6 megapixel camera. It creates a 3072 pixel by 2048 pixel image. At a byte per color (RGB) the raw size is: 3072 x 2048 x 3 = 18,874,368. Far more than your 16M limit, and consider the amount of memory also needed for the WordPress and Lazyest Gallery script.

What to do?

Simply said: Increase the amount of memory available to PHP. In the WordPress.org forums a lot of posts handle this issue. macmanx describes four ways to increase PHP's memory allocation:

  1. If you're using WordPress 2.9.2 or lower, try adding define('WP_MEMORY_LIMIT', '256M'); to your wp-config.php file. If you're using WordPress 3.0 or higher, WordPress automatically does this for a variety of tasks, so there's really no reason to try it in this case.
  2. If you can edit or override the system php.ini file, increase the memory limit. For example, memory_limit = 256M
  3. If you cannot edit or override the system php.ini file, add php_value memory_limit 256M to your .htaccess file.
  4. If neither of these work, it's time to ask your hosting provider to temporarily increase PHP's memory allocation on your account. Keep in mind that most decent hosting providers allocate 32 MB to PHP under each account, and most decent hosting providers allow users to temporarily increase the memory allocation. If your hosting provider won't accommodate you, perhaps it's time to find a new hosting provider.

If all four options fail

Try uploading smaller images like 800 pixels wide.

But it worked before!

Install Lazyest Gallery 1.0.16 (or higher).
After installing 1.0.16, go to Settings -> Lazyest Gallery and at the bottom of the screen, check Do not check Memory before creating images. This will skip the memory check and try to create a large buffer, risking to crash the PHP session for your gallery.