views:

426

answers:

6
Fatal error: Allowed memory size of 18874368 bytes exhausted (tried to allocate 1481725 bytes) in __/public_html/includes/database.inc on line 224

I'm having this error occur in Drupal 6 every time I try to edit the following pages (sorry about the xx's):

hxxp://chipkin.com/fs-8700-125-stulz

hxxp://chipkin.com/fs-8700-47-dnp-30

hxxp://chipkin.com/fs8700-14-ge-mark-iv-speedtronic

hxxp://chipkin.com/fs8700-74-veeder-root-serial-driver

We're on shared hosting so I don't have access to the php.ini file to allocate more memory, however I'm pretty sure that's not what's causing the problem. Any ideas?

+2  A: 

Definitely a memory problem -- it's going to be tough for you to run a Drupal site on only 18 megabytes of memory.

Your long term solution is to change hosts -- there are plenty of hosts that allow you to adjust php.ini (within limits). Bluehost.com is one example.

A possible short-term solution would be to remove unused modules from your modules directory. Each module eats up a little bit of memory even if it's disabled.

Things like caching and disabling statistics are good too, but they won't help much if you're getting memory problems on basic page edits.

anschauung
A: 

I'm not that familiar with Drupal, but is the page in question trying to grab a large amount of data from the database? Something like a SELECT * for an entire table? That may explain why one call is trying to allocate so much memory.

Changing hosts is an option, but for now it may be worth seeing if something can be done to limit the data requested from the database.

Unfortunately the error message doesn't to much to tell you what specific request is causing the problem - since the code making the db request is in the db library class. If you can do any kind of stack trace, it would help.

Tim Lytle
+1  A: 

I am on a shared host as well. Here is the PHP.INI that I created in one of the Drupal domain root folders:

[PHP]
memory_limit = 40M;
upload_max_filesize = 20M;
post_max_size 20M;
max_execution_time = 200;
max_input_time = 200;

I have no more problems with any global limits. I am not sure if the hoster can disable or override the local PHP.ini - mine does not, and it should be worth a try.

cdonner
Thank you all for your suggestions. This one did the trick. I don't know why I never tried this in the first place... If the php.ini file does not exist, don't assume its not accessible :(.
Cosmin
+2  A: 

You can specify the memory limit through .htaccess

Try adding the following line to the .htaccess file in your site's root directory:

php_value memory_limit 32M
codeinthehole
If the provider is worth his salt, this won't work. :)
Pekka
Agreed - this suggestion is all over the web, but never saw it work.
cdonner
A: 

I love Drupal, but I can't deny it's the most resource-hungry CMS I ever used. It is absolutely not uncommon to run out of memory even for relatively simple pages. CCK, Views, Panels and the batch API are specially prone to push your system beyond the limit.

18 Mb is absolutely an insufficient amount of memory to run a Drupal site even if with little traffic. I would say you should at least go to 5x that amount for peace of mind. Bare in mind that the amount of memory you consume on a developing site is much less than the one you consume in a production environment, where typically you will have more simultaneous page requests.

Drupal is only partly the culprit, though. Apache is the one that really sucks all the juice. A solution I am happy with, is to run my sites with nginx as HTTP server and php as fastcgi. You could also improve on this by using PHP-FPM, but as this is yet not part of the standard PHP distro, you will have to recompile PHP by yourself in this case.

If you are intrigued by the nginx solution, have a look to this drupal group. There are also a few answered questions on StackOverflow about this.

Hope this helps!

mac
A: 

edit settings.php (usually in sites/default) and add (or modify):

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

...or however you need.

Dr. Hfuhruhurr