Solving memory issues

When WooCommerce PDF Invoices & Packing Slips runs out of memory, you’ll get an error that looks something like this:

Fatal error: Allowed memory size of ######## bytes exhausted (tried to allocate ### bytes)

This could happen on batch actions or very large orders, sites with a lot of plugins, little memory, resource heavy plugins, or a combination of all of these. PDF creation is a memory intensive job, especially if it includes several pages with images.

Finding your WP memory limit #

Go to WooCommerce > PDF Invoices > Status (tab), here you can find your WP Memory Limit (as well as some other things that could affect plugin performance). We recommend setting it to 128mb or more (See: Increasing the WordPress Memory Limit). Note that setting this value higher than what your hosting allows doesn’t have any effect.

Further troubleshooting #

If you have increased the WP Memory Limit, but still don’t see any effect, or if you’re already at the limit of your site host, you can try to optimize the plugin and/or find what other processes use your sites resources. Sometimes there’s just a single plugin, badly coded, taking a lot of resources.

  1. Check that your WP Memory limit is actually used. You can take the first number from the fatal error and (“Allowed memory size of ######## bytes”), and divide that by 1048576 to get the M amount (i.e. 134217728 = 128M). Is this lower than your setting? Check if you have applied it correctly or contact your host.
  2. Use JPG instead of PNG. If your header logo/image is a PNG file, try replacing it with JPG. Unlike web pages (rendered in your browser), PDF is rendered on the server, and some servers have difficulties converting PNG to a format suitable for PDF, using lots of memory. JPG is often much lighter.
  3. Check logo resolution Check the resolution and/or filesize of the image file used for the logo. The resolution is printed in the General settings tab below the preview image. For print/online viewing, between 200-300dpi is optimal. If you change the logo, don’t forget to enable “Test mode” when reloading an existing invoice.
  4. Check your PHP version. Older PHP versions seem to use more memory. We’ve had reports of a 50% memory reduction when switchting from PHP 5.X to 7.X.
  5. Red or orange fields on the Status tab (WooCommerce > PDF Invoices > Status): ask your host about these to see if they can be resolved.