Fatal Error: Memory Exhausted During High User Load + Separate preg_match Warnings (WP 6.9, PHP 8.3.27)
Our site has suddenly become inaccessible, showing an error message on the frontend. The error log reports the following:
Code
PHP Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 4295229440 bytes) in /home/mysite/public_html/wp-includes/theme.php on line 325
PHP Warning: preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 2 in /home/mysite/public_html/wp-includes/class-wp.php on line 238
PHP Warning: preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 2 in /home/mysite/public_html/wp-includes/class-wp.php on line 239
Additional context:
- The fatal error occurred during aΒ live demo with about 50 users logged in and using the site simultaneously. The site became inaccessible with the fatal error above. Once we abandoned the demo, the site worked fine again.
- TheΒ
preg_match()Β warnings maybe areΒ not related to the memory exhaustionΒ β they occur daily and have been happening even before the fatal error issue.
Questions:
- Why is WordPress trying to allocate over 4GB of memory when my PHP memory limit is 2048M?
- Could theΒ
preg_match()Β warnings be fixed separately, since they seem unrelated to the fatal error? - Is the fatal error specifically related to concurrent usage/load, and what steps should I take to debug and fix it so the site can handle multiple users without crashing?
Troubleshooting already tried:
- Switched themes temporarily to confirm itβs not theme-specific (still occurs).
- CheckedΒ
.htaccessΒ rules for anomalies. - Verified no customizations in the default Twenty Twenty-Five theme.
- Site works fine under normal load, only crashes during high concurrent usage.
Iβm using theΒ default WordPress theme (Twenty Twenty-Five, Version 1.4)Β with no customizations.
Here is my Site Health info for reference:
- WordPress version:Β 6.9
- Database extension:Β mysqli
- Server version:Β 11.4.9-MariaDB
- Client version:Β mysqlnd 8.3.27
- Database charset:Β utf8mb4
- Database collation:Β utf8mb4_unicode_520_ci
- Max allowed packet size:Β 268435456
- Max connections number:Β 151
- Server architecture:Β Linux 5.14.0-427.40.1.el9_4.x86_64 x86_64
- Web server:Β LiteSpeed
- PHP version:Β 8.3.27 (64-bit support)
- PHP SAPI:Β litespeed
- PHP max input variables:Β 1000
- PHP time limit:Β 180
- PHP memory limit:Β 2048M
- Max input time:Β 90
- Upload max filesize:Β 1G
- PHP post max size:Β 1G
- cURL version:Β 8.14.1 OpenSSL/3.2.2
- SUHOSIN installed:Β No
- Imagick library available:Β Yes
- Pretty permalinks supported:Β Yes
- .htaccess rules:Β Custom rules added
- robots.txt:Β Dynamic (generated by WordPress)
WordPress constants / debug settings:
- WP_MEMORY_LIMIT: 40M
- WP_MAX_MEMORY_LIMIT: 2048M
- WP_DEBUG: Disabled
- WP_DEBUG_DISPLAY: Enabled
- WP_DEBUG_LOG: Disabled
- SCRIPT_DEBUG: Disabled
- WP_CACHE: Enabled
- CONCATENATE_SCRIPTS: Disabled
- COMPRESS_SCRIPTS: Undefined
- COMPRESS_CSS: Undefined
- WP_ENVIRONMENT_TYPE: Undefined
- WP_DEVELOPMENT_MODE: Disabled
- DB_CHARSET: utf8mb4
- DB_COLLATE: utf8mb4_unicode_ci
Any help or guidance would be greatly appreciated.
Thank you!
Find out which plugin is taking lots of memory. Please note, FluentCommunity takes a very minimul memory. So I think maybe you have a very big memory hungry plugin installed.
Shahjahan JewelΒ Iβve checked my setup and here are the plugins I currently use:
- Admin and Site Enhancements (ASE) β v8.1.1 (by wpase.com)
- Akeeba Backup CORE for WordPress β v9.1.1 (by Akeeba Ltd)
- Better Messages β v2.10.2 (by WordPlus)
- Content Control β v2.6.5 (by Code Atlantic)
- Fluent Forms β v6.1.11 (by WPManageNinja LLC)
- Fluent Forms PDF Generator β v1.1.11 (by WPManageNinja LLC)
- Fluent Forms Pro Add On Pack β v6.1.8 (by Fluent Forms)
- FluentCart β v1.3.2 (by FluentCart Team)
- FluentCommunity β v2.1.02 (by WPManageNinja LLC)
- FluentCommunity Pro β v2.1.02 (by WPManageNinja LLC)
- FluentSMTP β v2.2.92 (by FluentSMTP & WPManageNinja Team)
- LiteSpeed Cache β v7.6.2 (by LiteSpeed Technologies)
- Login with Google β v1.4.1 (by rtCamp)
- Members β v3.2.18 (by MemberPress)
- Open Graph β v2.0.2 (by Will Norris & Matthias Pfefferle)
- WordPress Importer β v0.9.5 (by wordpressdotorg)
- WP Activity Log β v5.5.4 (by Melapress)
I saw your note that FluentCommunity uses very minimal memory, so Iβm wondering: how can I actually find out which plugin is consuming the most memory on my site? Is there a recommended method or tool to measure plugin memory usage so I can identify if one of these is the culprit?
Diego MaradonaΒ Check with
- WP Activity Log
- Members by Memberpress
- Akeeba Backup CORE for WordPress
- Admin and Site Enhancements
All the fluent plugins run and execute code only in their associated context.
- WP_MEMORY_LIMIT: 40M? It is running or smart watches? Usually users have like 512M ++ I have on my powerful server 8192M
Drive ZoneΒ Where do I tweak this? Could that be the culprit? π
Drive ZoneΒ 8GB memory limit? :D that is not normal π
Here are some ideas - you can find it. These can be tricky but something is doing it.
Your WordPress settings are inconsistent:
WP_MEMORY_LIMIT = 40Mis very low for modern WordPress front-end.WP_MAX_MEMORY_LIMIT = 2048Mallows admin requests to use up to 2β―GB.
Recommended baseline for production:
PHP
// In wp-config.php
define('WP_MEMORY_LIMIT', '256M'); // front-end
define('WP_MAX_MEMORY_LIMIT', '512M'); // admin tasks
Show more lines
Then ensure PHPβs memory_limit is aligned (via php.ini, .user.ini, or .htaccess depending on your host):
php.ini
INI
memory_limit = 512M
Show more lines
.user.ini (if your host supports it)
INI
memory_limit = 512M
Show more lines
.htaccess (Apache with mod_php)
Apache Config
php_value memory_limit 512M
Show more lines
Keep the limit reasonable (512Mβ768M). If code tries to allocate ~4β―GB, you want it to fail fast so you catch itβraising to multiple gigabytes will mask the underlying defect and can crash the server.
Diego, that error shows that something in the theme was called - perhaps excessively or wrongly - by another plugin???? Open /wp-includes/theme.php and inspect around line 325 to see which WordPress function is being executed. This may give a clue.
It is also possible to have the WP log what is happening, then reproduce the errors and look in the log. Try this:
Edit wp-config.php:
// Debug to file, not to browser
define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', true);
// Optional: Log script loading details
This will write errors to /wp-content/debug.log.
Keep WP_DEBUG_DISPLAY false so the site doesnβt leak stack traces to visitors.
I hope that helps. I am new to FComm as well, but I bet it is one of those other plugins, not theirs. I say this because the GUI all runs in the browser, so likely it is another more traditional plugin. Some times it could be a conflict between plugins too.
I hope you can find it easily :)
Peace, Jamie
There is 2 issues, 1 is the PHP Fatal Error and the other one is 2 PHP Warnings, the warning is show in image here, on top of Feed page;
It could be a permalink issue. Backup your site first. Always backup with updraftplus or similar, so you don't lose anything when debugging.
You could try going to your WordPress admin dashboard: Settings > Permalinks. Note what your setting is now. It might be post or something. Then switch it to plain. Save and see if that fixes the error. If so, try switching it back. This can happen with custom permalinks. Sometimes just going thru this process can reset the problem. It is worth a try.
Also deactivating every plugin and theme - problem should go away - and activate each one by one.
Do you know what version of PHP your server is running. I just had to update mine to 8.03.