Sometimes when working with Drupal, you suddenly see this error: 
Allowed memory size of A bytes exhausted (tried to allocate B bytes)
or

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 3669969 bytes) in ../public_html/includes/theme.inc on line 1987

How to handle this error? That error message tells you that Drupal needed more memory than PHP was allowed to give it. In this article, I will explain to you 3 methods to increase PHP memory size, pick one that you like:

1. Fix the error in Drupal 6/7 using php.ini file

You will probably see this error message when you install new modules/themes. By default, Drupal 6/7 allocates 64M (megabytes) of memory on your website and so, to fix this issue you need to increase memory limit to higher value (128MB is fine).

Here is the solution:

1. Connect to your Drupal web hosting using SSH/FTP connection

2. Check if there’s php.ini  file in root folder of your hosting

3. If it’s existing, open the file with text editor (notepad) and add the value  php_value memory_limit = "128M"

4. If there’s no  php.ini file in root folder, then you need to create one. Use notepate, wordpad or whatever can edit and save text file as .ini  file add the value  php_value memory_limit = "128M"

5. Save the file if check the error’s gone

(Note: remember to save file with name: php.ini, not php.ini.txt)

2. Increase PHP memory using .httaccess

Edit the .htaccess file in the Drupal root directory. Look for the section:

Override PHP settings. More in sites/default/settings.php

But the following cannot be changed at runtime

Now add the following line:
php_value memory_limit 64M
This method will only work if PHP is running as an Apache module.

3. Using settings.php

If Drupal is already installed, you can edit sites/default/settings.php. This method will affect only the site using this file.
Locate the PHP settings section and add the following line at the end of that section:
ini_set('memory_limit', '64M');

That’s all for today, hope you will solve this issue immediately after reading this!

Drupal CMS with Free ASP.NET Hosting
Try our Drupal CMS with Free ASP.NET Hosting today and your account will be setup soon! You can also take advantage of our Windows & ASP.NET Hosting support with Unlimited Domain, Unlimited Bandwidth, Unlimited Disk Space, etc. You will not be charged a cent for trying our service for the next 3 days. Once your trial period is complete, you decide whether you'd like to continue.