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.

Template to Insert

Insert the below snippet in your 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.

RELATED:  WP Maintenance Mode Snippet without Plugin

Article last updated on November 11, 2020

Leave a Comment