• Resolved Abigailm

    (@abigailm)


    My error logs are filling up with lines that look like this:

    PHP Warning: Failed to set memory limit to 33554432 bytes (Current memory usage is ______ bytes) in Unknown on line 0

    There are hundreds of lines like this, so the error logs grow very quickly.

    I also sometimes see:

    PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate XXXXXX bytes) in /.../wp/wp-content/wflogs/rules.php on line 1397

    I am running PHP 8 on an Apache system using PHP-FPM. To debug I have tried to check everywhere I could think of to find why the system would be trying to set memory to 32M, as of course memory limits on my system are much higher than that.

    In reviewing my logs, I first see this error on 27 January 2022 — nothing prior to that. I have multiple sites on a virtual server running WordPress with Wordfence, and but am only seeing these errors on one site.

    Any suggestions as to what to look for to debug?

Viewing 1 replies (of 1 total)
  • Plugin Support wfpeter

    (@wfpeter)

    Hi @abigailm,

    Ultimately failures on the server with PHP when setting memory limits might be something your host or server administrator can assist with, but there are certainly a few things you can check first based on other cases I’ve seen.

    We currently don’t recommend using PHP8 as not all WordPress and associated plugin functions are 100% confirmed as compatible. There are sites that will work perfectly in a PHP8 environment but when you’re seeing issues, a rollback to the latest version of PHP7 available on your host could help.

    Next up, your WP_MEMORY_LIMIT should be set to 128M or 256M in wp-config.php. WooCommerce, for example, recommend 64M minimum, so if you also have many hits on the site at once especially during a Wordfence scan, a lower limit here could be reached fairly easily. Your PHP memory_limit value may already be set to 128M or 256M (or should be if they’re not) to accommodate this change, otherwise there won’t be enough room for WordPress to use the higher value it is requesting.

    It can also help to use my recommended performance setting options. By setting max_execution_time = 60 in php.ini (as lower or higher numbers can cause problems), Wordfence’s scan only ever attempts to use half of this value by default.

    Let me know how you get on!

    Peter.

Viewing 1 replies (of 1 total)
  • The topic ‘PHP Warning: “Failed to set memory limit”’ is closed to new replies.