Last updated October 9, 2013. Created by dman on January 6, 2008.
Edited by bserem, 1q84, LarsKramer, gpk. Log in to edit this page.

note: increasing PHP memory limit is different from increasing PHP upload size. You can learn to increase upload size here.

A PHP memory limit of 32MB is the minimum requirement for Drupal 7 (16MB for Drupal 6), and 64MB is recommended. Some sites may need more than 64MB if they are using certain contributed modules such as Views and Panels. Memory limits of 128MB and higher are not unusual. There are several techniques to increase the PHP memory limit and you only need to use one of them. The right one for you depends on your system configuration.

php.ini

This is the recommended approach if you have access to the server's php.ini. This will not be possible in some shared hosting environments, though your host may be able to adjust it for you. Note that this change will affect all websites and PHP scripts on the server.

  1. Locate the php.ini file used by your web server. You can click the "more information" link on Drupal's status page's PHP section. which shows the phpinfo() page. Locate the Configuration File (php.ini) Path row on that page. During installation Drupal checks the PHP Memory Limit, and if it is less than 32M (16MB for Drupal 6), an error message also provides the path to the php.ini file.
  2. Edit the memory_limit parameter in the php.ini file (usually in a section called Resource Limits)
    memory_limit = 64M  ; Maximum amount of memory a script may consume (64MB)
    If there is no section already for this, place the above line at the end of the file.
  3. Restart Apache.

php.ini in the Drupal root folder

Add the following line to a php.ini file in your Drupal root folder:
memory_limit = 64M
This will only work if PHP is running as CGI/FastCGI.

.user.ini in public_html folder (for PHP 5.3 and up)

PHP 5.3+ allows you to change the memory limit by placing a .user.ini file in the public_html folder.
Simply create the above file and type the following line in it:
memory_limit = 64M
Some cPanel hosts only accept this method.

The next two solutions are more restricted in scope and, in some cases, may be more appropriate choices than affecting all sites.

.htaccess

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.

and immediately after this add the following line:
php_value memory_limit 64M

This method will only work if PHP is running as an Apache module.

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');

Shared Hosting

In some shared hosting environments, access to the PHP memory limit setting is restricted. If you cannot make the change yourself, please ask your hosting provider to adjust it for you, or look for a new host that allows more flexibility.

For some hosts renaming php.ini to php5.ini may be necessary.

Some hosting services require the following line in .htaccess to enable a php.ini file.
suPHP_ConfigPath ~/public_html

For some hosts (CrazyDomains) you may need to add the following lines to the php.ini file (if they are not there already):

extension=pdo.so
extension=pdo_sqlite.so
extension=sqlite.so
extension=pdo_mysql.so

Modifying php.ini in local server environments

For MAMP see http://drupal.org/node/66187 particularly the "Optional: Adjust PHP's memory limit for scripts" section (note the difference for MAMP Pro).

If you are using XAMPP/WAMP, there may be two PHP.ini files (one under the PHP directory and the other under Apache/bin). To change your memory limit, edit the file in the XAMPP/Apache/bin directory.

Check your change has taken effect

In all cases, it pays to ensure that your change is actually working. Check Drupal's status report to verify that your memory actually is what you want it to be. If your change doesn't seem to be working, double-check the location of php.ini. Some systems have multiple copies of that file in different places. Only one is used and the others are red herrings.

Tools

For Drupal 6 you might want to try the Drupal Tweaks module which allows you to increase your PHP memory limit without editing any files.

XHprof is a good solution to find high memory consumption. See this page for more instructions on how to install and use it: http://groups.drupal.org/node/82889

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

If you're running a WHM-powered VPS you may find that you do not have permissions to edit PHP.INI directly; the system must do it. In the WHM host control panel, go to Service Configuration > PHP Configuration Editor.

-------------------------------------------
Interactive Worlds and Immersive Obsessions
http://www.asifproductions.com

In Plesk under that Websites and Domains tab you can click on the domain name in question. Then you will see a PHP Settings tab after clicking on the domain name, this screen will allow you to change the most common PHP settings, including the upload limit.

---Hope this helps

In all cases, it pays to ensure that your change is actually working. Use phpinfo to verify that your memory actually is what you want it to be. If your change doesn't seem to be working, double-check the location of php.ini displayed in the phpinfo page. Some systems have multiple copies of that file in different places. Only one is used and the others are red herrings.

To add to confusion, note that at least in the case of 1and1.com, phpinfo() actually responded with the higher memory_limit setting placed in settings.php, however the memory_limit was still the system-enforced 30MB. This observation was confirmed by 1and1 support. Also, fwiw, this memory limit is imposed on concurrent activity on the account overall, not per website on the account.

--
..happiness is point and click..
http://www.bronius.com

1and1 indeed does have a 30M memory limit on their shared plans.

This will run a basic drupal 6 install, but not much more, certainly not a Drupal 6 install with "default" contrib modules (CCK, Veiws, etc..). I thought I had resolved the issue via php.ini, htaccess, or drupal settings as phpinfo will report that you're memory has been increased, but the site memory errors always report that there is only 30M available. I called 1and1 today and confirmed that no such limit is in place on their cloud, VPS, or dedicated plans, but I have not confirmed that in practice yet..

http://faq.1and1.com/scripting_languages_supported/php/9.html

sg

Try using the file name php5.ini instead.

I found this to work on some hosting providers (GoDaddy, BlueHost among my managed sites). Just putting php.ini in the root didn't change the limit in the Status Report. I renamed it to php5.ini and then it registered.

I hope it helps.

James

good find!

I also specify the limit in settings.php like the example below. Do you?

ini_set('memory_limit', '256M');

For a detailed step-by-step solution to the memory error problem
"Fatal error Allowed memory size of"
for both Drupal 6 and Drupal 7 to easily increase the memory allocation to 128M, see...

Drupal 7 Fatal error Allowed memory size of ...
http://drupal.org/node/76156#comment-4582924

..or..

Drupal 7 memory increase to more than 128M,
that may or may not work for Drupal 6, see...
http://drupal.org/node/76156#comment-4583384

"All the best; intended."
- Chris
___

Drupal 8 is great.

Re: Dupal 9,000
Three-minute Video on the problem
of technology out-pacing users.
http://great-grandma.com/gill_bates-dead_at_42/index.html

unfortunately all these nice modification on settins etc didi not work at all for me

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 261904 bytes) in ..\...\xampp\htdocs\drupal\modules\taxonomy\taxonomy.module on line 928

I don ot know what is happening. surely some conflict with some module which drains a lot mf memory looping.

can anyone help me?

32M - which is what you have there - is not enough for the number (or type) of modules you have enabled.
Identifying which might be the heavy ones can only be done by you at your end, and is tedious.
You will have to just increase your memory limit, using whatever method described here that works. try 64M.

it is not a matter to be tedious,

i see as much as you raise memory limit up much more drupal request is higher.

so it's a loopy tricky game.

not sure if this is going to be solution.

I do not understand why with just 20-30 additional modules DRUPAL become an hell and it is non utilizable at all. just getting slow, plenty of errors and impossible to manage ti!

i do not know how other developers can put together a decent drupal webpage with these problems .

The setting.php method worked for me know my site www.daenotes.com run with out the error message. [memory exhausted......] thanks for the info.

In PHP.ini I can set memory_limit = -1 to indicate "no memory limit" use all that is available. Can I do this in settings.php ini_set('memory_limit', '-1'); to have the same effect?

Best regards

Sridhar

Acer Aspire 5745
[i5 430M, 3GB, 320GB]
Ubuntu 12.04 (Precise Pangolin)
Drupal 6.15, 7.x
Aware Hosting, DigitalOcean, Go Daddy, LimeDomains, Rackspace, Tata Instacompute

@sridharpandu: Maybe you want to try this out? It shouldn't be too hard to change the parameter and go to the status report page.

However, for people running Suhosin patch this setting is neither valid in php.ini nor anywhere else (and is handled as an illegal attack).

@asb, I am running all my sites with suhosin! I just used it on one ocassion on a slicehost VPS, I didn't install the suhosin patch though. But as of now all the sites I run have the suhosin patch.

Acer Aspire 5745
[i5 430M, 3GB, 320GB]
Ubuntu 12.04 (Precise Pangolin)
Drupal 6.15, 7.x
Aware Hosting, DigitalOcean, Go Daddy, LimeDomains, Rackspace, Tata Instacompute

php_value memory_limit = "128M"
extension=pdo_sqlite.so
extension=sqlite.so
extension=pdo_mysql.so
# added the file as php.ini and loaded in public_html

I just had this problem while trying to enable a commerce module. admin/modules/confirm gave me an out of memory warning when enabling price module. Surprisingly I had 128MB available in my php.ini but needed more. If anyone has this problem I'd suggest trying to increase the memory limit to something crazy like 512MB temporarily and to disable and re-enable the module again. Worked for me but I couldn't believe I might need more memory than this. Remember to restart apache after adjusting php.ini file. I've put my memory limit down to 128MB again after enabling the module in question.

Hi,

I have 1&1 and they cap their 'Business Linux' shared hosting accounts' php memory limit at 90MB - and they don't offer any accounts with a higher limit. I have recently run into the problem described in these forums: http://drupal.org/node/1397450, http://drupal.org/node/1561450.

I contacted 1&1 and they told me that this error is definitely a php memory error - and that they can't do anything about it. Can anyone recommend a hosting provider who has a higher max php memory limit, like 128M, 256M, or even 512M?

@yev.ananin: Avoid incompetent managed hosting - if that's what 1&1 is doing, they are incompetent. Go for a root server, or look for a managed hosting that actually supports Drupal. You can find some companies with proven Drupal know-how at the marketplace, or you can drop me an email if you are interested in individual experiences. However, this is not the right place to discuss Drupal hosting, please use the forums for that.

since those are drupal® affiliate links
and are hosting companies that support Drupal technically
and financially when you use the links on page

The Drupal.org "Hosting" page
http://drupal.org/hosting

"All the best; intended."
- Chris
___

Drupal 8 is great.

Re: Dupal 9,000
Three-minute Video on the problem
of technology out-pacing users.
http://great-grandma.com/gill_bates-dead_at_42/index.html

I have now been happy with BlueHost for 4 years.

Use their link on the drupal.org page
http://drupal.org/hosting
and they give all the proceeds to Drupal.org .

I recommend you buy three years at $4.95 / month to avoid the hassle
of renegotiating it down from $7.95 when your first contract expires.

Unlimited website storage, unlimited bandwidth, 50 MySQL Databases.

Using the free BlueHost control panel
automated Drupal installer "SimpleScripts" (not Fantastico)
I can 'one-click' install a test Drupal 6 or 7 site (up to 50 of them),
And the memory is automatically set to 128M (for Drupal 7).

"All the best; intended."
- Chris
___

Drupal 8 is great.

Re: Dupal 9,000
Three-minute Video on the problem
of technology out-pacing users.
http://great-grandma.com/gill_bates-dead_at_42/index.html

I agree with Christopher James Francis Rodgers about Bluehost (or Hostmonster; they are the same company.) I've been using them for about 3-4 years now. For an inexpensive shared server setup, they are amazing.

Are bluehost also justhost.

I have got emails from bluehost before with my justhost details???

I have increased php to 128M on my MAMP, do you know if this is okay to run on justhost?

Thanks if you can answer, but I know it's a shot in the dark, after a long evening fixing a WSD.

cd

Thanks, I nearly gave up and did reinstall of MAMP on my D7 install, losing hours of work.

But I changed the settings.php file as you suggested and it got rid of the WSD and I got back into my admin menu.

Now site is backed up and I haven't lost an evenings work.

Thanks and subscribing to this post in case I get another issue.

cD

Someone please help me, i got this error since two week...
Resource Limit Is Reached
The website is temporarily unable to service your request as it exceeded resource limit. Please try again later.

Delhiwonders

See comment above: FYI

(Ditto from comment 'FYI' above:)

Drupal 7 "Fatal error: Allowed memory size of ...":
http://drupal.org/node/76156#comment-4582924
...to increase your memory allocation to
128M. (Works with Drupal 6, also-- I think.)

..or..

Drupal 7 memory increase to more than 128M
http://drupal.org/node/76156#comment-4583384
...that may or may not work for Drupal 6:

"All the best; intended."
- Chris
___

Drupal 8 is great.

Re: Dupal 9,000
Three-minute Video on the problem
of technology out-pacing users.
http://great-grandma.com/gill_bates-dead_at_42/index.html