Error

Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 8192 bytes) in

/wp-includes/template.php on line 791

Solution

The "Fatal error: Allowed memory size of 1073741824 bytes exhausted" in WordPress typically indicates that the PHP memory limit has been reached. This can happen due to various reasons such as large media uploads, inefficient plugins, or themes, or simply because the default memory limit set by the hosting provider is not sufficient for your site's needs.


To resolve this issue, you can try the following methods:


1. **Increase the PHP Memory Limit**: You can increase the memory limit by editing the `wp-config.php` file. Add the following line of code just before the line that says, `That's all, stop editing! Happy blogging.`:

```

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

```

This will increase the memory limit to 256MB, which should be sufficient for most WordPress sites. If this doesn't resolve the issue, you may need to try a higher value like '512M' .


2. **Edit the .htaccess File**: If you cannot access the `wp-config.php` file or the above method doesn't work, you can try adding the following line to your `.htaccess` file:

```

php_value memory_limit 256M

```

This method sets the memory limit for PHP to 256MB and can be useful if your hosting provider doesn't allow modifications to the `php.ini` file .


3. **Contact Your Hosting Provider**: If neither of the above methods works, it might be necessary to contact your hosting provider to request an increase in the PHP memory limit. Some shared hosting environments have strict limits to ensure fair usage among all users on the server .


Remember to always back up your site before making changes to core files like `wp-config.php` or `.htaccess`. If you're unsure about any of these steps, it's best to consult with a professional or your hosting provider's support team for assistance.