One common issue that can plague a WordPress site is the dreaded “PHP Fatal error: Allowed memory size of 26843546 bytes exhausted”. There are many reasons PHP may run out of memory in WordPress but typically it’s because you’re hitting PHP’s memory limit in your hosting environment. Luckily you can change WordPress memory limit with a variable in your wp-config.php.
So if you’re seeing a fatal PHP error like the one below you’re in the right place:
PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 12288 bytes) in /sites/smartwp.co/wp-includes/plugin.php on line 584
Increase PHP Memory Limit in WordPress
To increase the PHP memory limit in WordPress you’ll need to be familiar with FTP and editing PHP files. Login to your server’s FTP so you can edit your site’s wp-config.php in the root of your WordPress install. Adding the snippet below will increase the memory limit to 256mb. This should be more than enough for most WordPress sites.
This snippet can be added before the line that says “Happy Blogging” in your site’s wp-config.php file.
By default the WordPress memory limit is 32mb.
Increase the PHP Memory Limit in PHP.ini
If the above doesn’t work you may need to edit your server’s php.ini file to increase your memory limit. This can be done by modifying the “memory_limit” line in your php.ini file.
If none of these changes work to change your memory limit in WordPress you can also reach out to your web host for more help. There could be an issue with code on your site or something your web host has implemented.