How to Increase PHP Memory Limit in WordPress?

Purpose of Code Snippet

PHP is the backbone of WordPress. In order to protect the hosting servers, many web hosting companies limit the memory limit and execution time of PHP scripts in WordPress site. however, you have to keep sufficient memory limit for certain processes to run on your site. If you always get memory exhausted error, here is a snippet you can use to increase PHP memory limit in WordPress site.

Where to Insert the Snippet?

  • Login to your server using FTP account.
  • Go to the root of your WordPress installation.
  • Locate config.php file and insert the below snippet.

Alternatively, you can use File Manager app from your hosting account to edit config.php file.

Code Snippet

define('WP_MEMORY_LIMIT', '96M');

96M indicates, 96MB of memory for running PHP scripts. You can change the value as per your need like 256MB or 512MB. However, make sure to confirm with your hosting company for the maximum allowable limit.

Note: Many popular hosting companies like SiteGround offers PHP Manager app in your hosting account. You can use this app and modify the memory limit without editing config.php file.

Leave a Comment