White screen of death or HTTP error 500 due to Memory limit

Recently, we have got an error called as White screen of death (HTTP error 500), when trying to setup an Woocommerce store. The error was appearing immediately when the Woocommerce plugin is activated.

We thought it is an random issue hence,have re-installed WordPress also few times, disabled/enabled and installed/uninstalled Woocommerce so many times but nothing seems working properly with Woocommerce.

Earlier,

  1. the site was getting crashed immediately when the plugin is activated.
  2. Later it is crashed when running the Woocommerce setup
  3. and once while Paypal payment setup
  4. Another time when Storefront theme installation

Have skipped those problematic setups after that site is ok but not able to install any plugin or theme as getting the below error.

An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.

By not understanding the issue with above error, WP_DEBUG is enaled in wp-config.php to get the error displayed in the front screen (Development site, try logging into a file in Live site).
Below is the error which appears on the front screen, if WP_DEBUG is enaled in wp-config.php of wordpress installation.

Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 21 bytes) in some file

With the above, understood that the site is getting crashed because of the memory issue. To know the existing memory limit phpinfo() function in phpinfo.php can be used.

The memory can be increased at different levels.

  1. WP_MEMORY_LIMIT – This is probably to set the limit for Memory usage in WordPress site. This can be set in wp-config.php file of the wordpress installation. Here it can be increased from default memory size to desired by adding the below line at the end of file(if not exists already in the file). Below will increase the limit to 64MB
    define( 'WP_MEMORY_LIMIT', '64M' );

    After doing the above change, go and check front page where the fatal error was displayed, if the site is normal then it is fixed, otherwise follow the below step.
  2. PHP version memory – If the above step is not effective means the PHP memory limit need to be changed at higher level i.e. Account/Server level. This also can be changed at 2 levels i.e. cPanel(User account level) and WHM panel(server level).

    First try changing at cPanel level if access is available as below.
    cPanel –> Software –> MultiPHP INI Editor –> Select the location –> memory_limit. Change the value to desired limit. Changing it to -1 will make it NO Memory limit which may eat up all the server memory, Hence it is better to have some limit. In this case 256M is used.

    If WHM panel access available this can be changed as below.This change will be effective across all cPanel accounts.

    WHM panel –> Software –> MultiPHP INI Editor –> Select the PHP version –> memory_limit. Change the value to desired limit. Changing it to -1 will make it NO Memory limit which may eat up all the server memory, Hence it is better to have some limit. In this case 256M is used.
    After doing the above change, go and check phpinfo page again, this time it should be effective.

4 thoughts on “White screen of death or HTTP error 500 due to Memory limit”

  1. "youtube seo tool"

    That is a rezlly good tip particularly to those new to the blogosphere.

    Brief but very precise info… Thank you forr sharing thgis one.
    A must read article!

Leave a Comment

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