Getting the “Allowed memory size exhausted” error or a white screen in WordPress? Then PHP doesn’t have enough memory to load your site. By default, WordPress reserves only a limited amount of RAM per process, while plugins, themes, and images demand more and more. The solution is to increase the memory limit via wp-config.php, .htaccess, or php.ini. Below you’ll find how each method works and how to check whether it was successful.
Why a memory limit error occurs
PHP assigns each script a maximum amount of working memory. WordPress itself sets an additional limit on top of that via the WP_MEMORY_LIMIT constant. If this is too low, your site will get stuck as soon as a plugin, import, or backup needs more memory than is available. Recognizable signs include:
- “Fatal error: Allowed memory size of X bytes exhausted”
- A white screen with no error message (White Screen of Death)
- Slow or unresponsive admin pages
- Plugins that won’t activate
- Failed backups or large media uploads
This mainly occurs on sites with many plugins, webshops (WooCommerce), or large media libraries. Increasing the memory limit solves this immediately, as long as the hosting environment allows it.
Increasing the memory limit: three methods
Depending on your hosting environment, you can choose from three ways to increase the limit.
1. Via wp-config.php (recommended)
This is the most direct and portable method, and works on almost any hosting environment, including LiteSpeed servers.
define('WP_MEMORY_LIMIT', '256M');