简体   繁体   中英

DRUPAL: Fatal error: Allowed memory size error when editing specific existing pages

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.

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.

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

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.

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.

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

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

...or however you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM