Solution: “Fatal Error Allowed Memory Size” X Bytes WordPress 1 Min Fix
If you are getting the error like this one
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 35 bytes) in /home/content/28/10588428/html/wp-includes/wp-db.php on line 2255
There are 2 simple solutions to the Allow memory size error. The first fix includes making a few changes that takes seconds to do.
PHP.INI SOLUTION
Where Is It: Root Folder in your hosting account
File Name: php.ini
Line Number To Change: 4
Solution: Change The Memory Limit
Change The Memory Limit From This: memory_limit = 128M
Change The Memory Limit To This: memory_limit = 256M or To This: memory_limit = 512M
DEFAULT-CONTSTANTS.PHP SOLUTION
Where Is It: wp includes folder
File Name: default-constants.php
Line Numbers to Change: 23 and 28
Change The Memory Limit On Line 23 From This: ‘WP_MEMORY_LIMIT’, ’40M’
Change The Memory Limit On Line 23 To This: ‘WP_MEMORY_LIMIT’, ‘128M’
Then Change The Memory Limit On Line 28 From This: if ( ! defined( ‘WP_MAX_MEMORY_LIMIT’ ) ) {
define( ‘WP_MAX_MEMORY_LIMIT’, ‘128M’ );
Then Change The Memory Limit On Line 28 To This: if ( ! defined( ‘WP_MAX_MEMORY_LIMIT’ ) ) {
define( ‘WP_MAX_MEMORY_LIMIT’, ‘512M’ );
Here’s What The Code Will Look Like:
Default Constants Solution Code
This is what the default-constants.php code looks like. The 23rd and 28th lines are the ones you want to change to 128M and 512M. You can’t break it by raising this number to either of those numbers so don’t be scared to give it a shot.
21 define(‘WP_MEMORY_LIMIT’, ’64M’);
22 } else {
23 define(‘WP_MEMORY_LIMIT’, ‘128M’);
24 }
25 }
26
27 if ( ! defined( ‘WP_MAX_MEMORY_LIMIT’ ) ) {
28 define( ‘WP_MAX_MEMORY_LIMIT’, ‘512M’ );
29 }
PHP.INI Solution Code
This is what the php.ini code looks like. The 4th line is the one you want to change to 128M or 256M. If 128 doesn’t work, just try 256. You can’t break it by raising this number to either of those numbers so don’t be scared to give it a shot.
1 register_globals = off
2 llow_url_fopen = off
3
4 memory_limit = 256M
Or
1 register_globals = off
2 llow_url_fopen = off
3
4 memory_limit = 512M
Hope This Helped
Hope this helps you solve you problem. If this helps you, please leave a comment and share this page.