3
votes

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:

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.

5
What makes you think memory isn't causing the 'out of memory' error? - Mike B
Are you using CCK? That one happens to gobble up pretty much memory usually. - Joey
Mike: My reasoning is that we have other pages with much more content and memory usage that are not causing any problems. I might be wrong. Johannes: We are using CCK, however we can't disable this. - Cosmin
@anschauung is saying everything substantial below, but a database operation that eats 1.4 MB in one go is a bit odd in my opinion. You may want to investigate that as well. - Pekka

5 Answers

2
votes

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.

2
votes

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
1
votes

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.

0
votes

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.

0
votes

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

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

...or however you need.