• Resolved awalford

    (@awalford)


    I am confused by a server 500 memory issue. I read your top post about 500 Internal Server errors but still unsure about something.

    When I complete an order and the invoice is automatically generated and emailed, about 20% of the time I get a server 500 error. Otherwise, it works.

    I turned on debug log and I see this:
    [17-Jan-2020 19:28:30 UTC] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 16207361 bytes) in xxx/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/vendor/dompdf/dompdf/lib/Cpdf.php on line 5015

    134217728 corresponds to 128MB

    16M is a lot to allocate for a single page, single pdf invoice it seems. Regardless …

    I looked at a few things:
    a) The PDF Invoice Status page memory status says: WordPress: 40M, PHP: 256M
    b) The woocommerce status page says: WordPress memory limit: 256 MB
    c) If I call php_info() and dump the results I see: memory_limit 128M

    So 128MB does seem to be the default for the php memory limit setting, and the error message says 128M so that seems to correspond. But WordPress status’s say 256M. Who is right? Should I use my php config to increase it to 256M even though WP thinks it is already 256?

    I do have quite a few plugins.

    Lastly, the PDF Invoice status page has this link but it no longer goes anywhere useful on the wp site:
    https://codex.www.ads-software.com/Editing_wp-config.php#Increasing_memory_allocated_to_PHP

    Alan

Viewing 4 replies - 1 through 4 (of 4 total)
  • I have a similar issue, hope fully someone can clarify

    This was a fatal error in the log

    2020-01-14T19:48:33+00:00 CRITICAL Allowed memory size of 134217728 bytes exhausted (tried to allocate 155648 bytes) in /home/j3cda0dysorx/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 423

    2020-01-14T21:14:56+00:00 CRITICAL Allowed memory size of 134217728 bytes exhausted (tried to allocate 10485760 bytes) in /home/j3cda0dysorx/public_html/wp-content/plugins/woocommerce-pdf-invoices-packing-slips/vendor/dompdf/dompdf/src/Css/Color.php on line 192

    https://docs.woocommerce.com/document/increasing-the-wordpress-memory-limit/

    I just followed the directions on this support page to increase wordpress memory to 256m. Seems to have taken care of the fatal error.

    Plugin Contributor Ewout

    (@pomegranate)

    Hello Alan,
    Thanks for reporting about the broken link, I’ll correct this in the next update!
    Answering your question:

    Who is right?
    PHP (or more precise: the limit displayed in the final error) is.

    1. WordPress allows overriding the memory limit via a setting (constant) in wp-config.php, as described in the codex (correct link this time ;)). Your server may not allow overrides at this level, but our plugin is unable to tell that from just looking at the settings (40M in your config, which is ignored by PHP).
    2. PHP allows overriding the memory limit via the ini files. We read this setting via ini_get( 'memory_limit' ), which on your site returns 256M – incorrectly. This is what both our plugin and WooCommerce report.
    3. There may be a physical limit (or higher, server level cap) on your hosting. In that case setting it to a higher value will not make any difference. I think this may be what is happening on your site.

    I recommend reaching out to your host to ask if they can increase the limit for you.

    The memory usage of our plugin largely depends on your PHP version and specific setup. If you have a very high resolution header image for example, this is processed uncompressed when creating the PDF, and additional operations are performed if it is PNG. I recommend JPG at 300 dpi (you can see the resolution below the preview in the settings), this is much ligher both to process and in the resulting PDF.

    Hope that helps!

    Thread Starter awalford

    (@awalford)

    Thanks Ewout. On our Apache server, we use the .user.ini config file to add php variables. I added
    memory_limit = 256M

    and now php, php_info, woocommerce and your status page all report 256M. So I think that should be better. I will monitor it for any crashes.

    Our invoice does have a 850dpi image header. So that may be the reason. It does not always fail but I guess it depends on how much WP and other plugins are consuming.

    Fingers crossed it is all good now.

    Thanks for your help.
    Alan

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Don’t understand my memory issue and server error’ is closed to new replies.