Title: PHP Warning: &#8220;Failed to set memory limit&#8221;
Last modified: March 1, 2022

---

# PHP Warning: “Failed to set memory limit”

 *  Resolved [Abigailm](https://wordpress.org/support/users/abigailm/)
 * (@abigailm)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/php-warning-failed-to-set-memory-limit/)
 * 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](https://wordpress.org/support/users/wfpeter/)
 * (@wfpeter)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/php-warning-failed-to-set-memory-limit/#post-15417927)
 * Hi [@abigailm](https://wordpress.org/support/users/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](https://www.wordfence.com/wp-content/uploads/2021/09/maxexescanperformance.png).
   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.

 * ![](https://ps.w.org/wordfence/assets/icon.svg?rev=2070865)
 * [Wordfence Security - Firewall, Malware Scan, and Login Security](https://wordpress.org/plugins/wordfence/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordfence/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordfence/)
 * [Active Topics](https://wordpress.org/support/plugin/wordfence/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordfence/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordfence/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [wfpeter](https://wordpress.org/support/users/wfpeter/)
 * Last activity: [4 years, 3 months ago](https://wordpress.org/support/topic/php-warning-failed-to-set-memory-limit/#post-15417927)
 * Status: resolved