Fatal Error: Allowed Memory Size of – Fix Allowed memory size exhausted with WordPress and php

To fix a fatal memory error in PHP when using WordPress on Windows (such as “Allowed memory size exhausted”), you need to increase your PHP memory limit. This issue happens when your website needs more memory than your server or PHP settings allow.

Edit wp-config.php:

  • Locate the wp-config.php file in your WordPress root directory (often htdocs or public_html).
  • Add this line just before the line that says /* That's all, stop editing! Happy blogging. */:
define('WP_MEMORY_LIMIT', '256M');

Save and close the file. This raises the PHP memory limit to 256 megabytes

Change php.ini (if needed):

  • Find the php.ini file in your server or hosting environment (use your hosting control panel or locate it in your XAMPP installation, usually at xampp/php/php.ini).
  • Open it and look for the line starting with memory_limit. Change it to:
memory_limit = 256M
      • Save the file and restart Apache to apply changes.
      Edit .htaccess (if using Apache):
      • Open (or create) the .htaccess file in your WordPress root directory.
      • Add this line (preferably after # END WORDPRESS):
php_value memory_limit 256M
  • If your site still shows a memory error after these changes, your hosting provider might have a hard limit. In this case, contact them for support or consider upgrading your hosting plan.