Last updated on January 23rd, 2022 at 09:34 am

WordPress sometimes starts throwing error similar to

[Wed Jan 15 14:12:49 2012] [error] [client xxx.xxx.xxx.xxx] PHP Fatal error:  Out of memory (allocated xxxxxx) (tried to allocate xxxxxx bytes)

We basically end up checking and increasing php memory settings, enabling and disabling plugins etc., But ultimately nothing will work out.
The same issue happened with my VPS and was surprise to see even in VPS we receive these error. It starts throwing error in vps too as long as we have the memory limit inside wordpress configuration set to a small value.

The above error is always an issue for web developers and the website starts throwing 500 internal server error since it doesn’t have enough memory to compile and display the page that the client / browser is requesting. This might be due to various reasons.

Sometimes this issue will not get fixed even after modifying memory_limit value in php.ini, our users use to complain that they have set the memory limit for php to a higher value but still they are seeing php fatal error in the logs while running wordpress scripts.
This is because wordpress has some other local settings for memory limit. The setting in wordpress related to memory can be found it wp-config.php file.

The value to look for is define(‘WP_MEMORY_LIMIT’, ‘256M’);

Basically it is recommended that we have the MEMORY_LIMIT in PHP.INI and WP_MEMORY_LIMIT in wp-config.php should be the same.

The above memory limit 256 Mega Byte is just given for your understanding. Please check with your hosting provider and increase the memory to another value if you are not sure about memory management.
Giving a very higher value for the memory is not the best solution to resolve any application memory related issue.

Leave a Reply

Your email address will not be published. Required fields are marked *