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.

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.

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. Try enabling the “Use DOMDocument to parse HTML” option in the Status tab This may not work on all sites, but in some cases this uses a lot less memory.
  2. 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.
  3. Run P3 Profiler: To get an impression of which plugins use the most of your resources, you can install P3 Profiler plugin (free). This plugin lets you scan your site and then gives a report of which plugin used the most resources. Don’t run it on auto! This will not give you representative results for this specific scenario. Run it on manual, visiting several typical WooCommerce backend and frontend pages. Are there any plugins in the results taking up a lot of memory? Try looking for alternatives or ask the plugin developer why it’s using so much resources.
  4. 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.
  5. 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.3 to 5.4 or higher.
  6. Red or orange fields on the Status tab (WooCommerce > PDF Invoices > Status): ask your host about these to see if they can be resolved.