I have been getting consistent "Out of memory" errors that I need help diagnosing.

My site is hosted on Media Temple (gs)

Drupal version 6.20
PHP Version 5.2.14
Drush version 4.2
PHP Memory Limit 99M -- according to phpinfo()

The errors I have been getting, specifically:

  • Fatal error: Out of memory (allocated 72089600) (tried to allocate 30720 bytes) in ~/sites/all/modules/panels/plugins/export_ui/panels_layouts_ui.class.php on line 157
  • Fatal error: Out of memory (allocated 71827456) (tried to allocate 262200 bytes) in ~/includes/menu.inc on line 966
  • Fatal error: Out of memory (allocated 71565312) (tried to allocate 76 bytes) in ~/modules/update/update.module on line 573
  • Fatal error: Out of memory (allocated 72089600) (tried to allocate 71093 bytes) in ~/includes/database.mysql-common.inc on line 41

99M seems like enough memory -- esp since the errors are happening way below 99MB.

Comments

alex’s picture

it can be Apache memory limit, RLimitMEM. phpinfo() wouldn't know about it.

estherswhite’s picture

Thanks -- Do you know how to find out what my Apache memory limit is?

I added this line to my .htaccess RLimitMem 128000000 based on recommendation from following thread: http://drupal.org/node/463234#comment-1942458

But it didn't prevent me from getting "Out of memory" errors.

alex’s picture

The .htaccess directive won't have any effect if overriding is not allowed in main Apache config. I guess you'll have to speak to your hoster.

estherswhite’s picture

I got a reply from my host -- they said:

Currently, your web application is functioning without any resource issues. This may be an issue with your MySQL database. You may want to attempt to log into your database once this occurs and check the 'Processes' feature using phpMyAdmin. You would be able to see any queries that may be hanging. Hanging or sleeping queries can use up resources which can cause these errors. You would be able to locate and resolve any query issues to prevent these outages in the future.

I logged into phpMyAdmin and the Processes page doesn't give me any information at all.

However, today, I noticed that I am getting a lot more errors and many of them are related to ~/includes/database.mysql.inc

  • Fatal error: Out of memory (allocated 71565312) (tried to allocate 7680 bytes) in ~/sites/all/modules/ctools/plugins/export_ui/ctools_export_ui.class.php on line 1308
  • Fatal error: Out of memory (allocated 71565312) (tried to allocate 30720 bytes) in ~/sites/all/modules/backup_migrate/includes/destinations.file.inc on line 42
  • Fatal error: Out of memory (allocated 72089600) (tried to allocate 524236 bytes) in ~/includes/menu.inc on line 966
  • Fatal error: Out of memory (allocated 72089600) (tried to allocate 256 bytes) in ~/sites/all/modules/views/includes/view.inc on line 1748
  • Fatal error: Out of memory (allocated 70254592) (tried to allocate 717534 bytes) in ~/includes/database.mysql-common.inc on line 41
  • Fatal error: Out of memory (allocated 72089600) (tried to allocate 24 bytes) in ~/includes/database.mysql.inc on line 168
  • Fatal error: Out of memory (allocated 72089600) (tried to allocate 78 bytes) in ~/includes/database.mysql.inc on line 166
  • Fatal error: Out of memory (allocated 71827456) (tried to allocate 82 bytes) in ~/sites/all/modules/views/includes/base.inc on line 88
  • Fatal error: Out of memory (allocated 70516736) (tried to allocate 1205667 bytes) in ~/includes/database.mysql.inc on line 310
  • Fatal error: Out of memory (allocated 72089600) (tried to allocate 64 bytes) in ~/sites/all/modules/backup_migrate/includes/destinations.inc on line 782
  • Fatal error: Out of memory (allocated 69730304) (tried to allocate 1360678 bytes) in ~/includes/database.mysql-common.inc on line 41

Anyone ever have a similar issue with MySQL? Where should I look next? Many thanks!

artatum’s picture

1) disable ALL modules that are not strictly necessary.
2) run your cron
3)flush your cache in admin/performance
4) dont cry : 1and1 limit is 32 M, as most of hosters, and you've got probably 72M. You're probably too fat...
I bet everything will go fine after. Give it a try.

alex’s picture

Your issue is not directly MySQL related. It could be either because of some resource consuming module or feature you are using, or a rogue piece of custom code if you have any. The exact location of the error message with file name and line number is not important here.
artatum gave you a good advice; If I were you, I would also look into changing your hosting provider to something with more resources and more helpful support.

estherswhite’s picture

I enabled verbose error logging and have found these errors in my log in addition to the out of memory error:

PHP Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in ~/includes/common.inc(1696) : eval()'d code on line 1, referer: ~/admin/settings/search404

Am I getting the syntax error bc I'm out of memory or are they separate?

alex’s picture

Those are errors thrown by search404 module or some block on the page when you visit its config page. They are likely to be unrelated.

estherswhite’s picture

I'm finding that I can actually get this error on almost any page if I re-build the cache or if I am on a page that requires the site to load information that isn't cached -- like ~/admin/content/node-settings/rebuild or ~/admin/settings.

Examples:
PHP Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in ~/includes/common.inc(1696) : eval()'d code on line 1, referer: ~/admin/settings
PHP Fatal error: Out of memory (allocated 72089600) (tried to allocate 80 bytes) in ~/html/includes/menu.inc on line 966, referer: ~/admin/settings
PHP Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in ~/includes/common.inc(1696) : eval()'d code on line 1, referer: ~/admin/settings/performance
PHP Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in ~/includes/common.inc(1696) : eval()'d code on line 1, referer: ~/accommodations

These pages in particular don't have any blocks on them, so I don't think it can be attributed to a block. What other parts of the site could give issues on common.inc (assuming this isn't just a PHP memory problem)?

(Also -- my host insisted that it I needed more memory for my database so I have a trial MySQL GridContainer, doesn't seem to be helping at all.)

Thank you, I'm at a loss as to what to do next!

alex’s picture

Interesting.
It looks like drupal_eval is called on every page of yours with some malformed code, which could give some clues to what's really happening.
Personally I would quickly edit includes/common.inc and put
die($code)
on, say, line 1693.
It should cause any of the affected pages to display rogue code and exit;
After checking the code, the edited file can be promptly restored to its additional state.

prokopton’s picture

estherswhite’s picture

I ended up switching hosts and now my memory problems are fixed. I don't now what the issue at Media Temple is --- but they reported 99MB but I wasn't getting it. (I'm on DreamHost now, and I am running well below 99MB on a VPS.)

prokopton’s picture

Sometimes the host is problem. Sometimes it's our configuration. Sometimes a hired designer/programmer can create rogue code that consumes excessive memory.

Many variables in an issue like this.

mikeejt’s picture

I ran into the same issue w/ Media Temple...they said to add

memory_limit = 99M

in my local php.ini (/Home/etc/). That increased the limit about 3mb more, but it still isn't working.

I'm trying to avoid switching hosts, so I'll post updates as I get them. This sorta sucks though...

charlie-s’s picture

+1 for RLimitMem. Added this to my .htaccess to handle a spike in admin activity that I couldn't get done otherwise:

RLimitMem 512000000

I didn't know this option existed.

sajosh’s picture

I was able to resolve the memory problems by clearing the cache button in the admin>performance page. It seems to be temporary but at least i'm able to proceed with what i need to get done. the errors continue to occur at some pages but this seems to be a stop gap measure until a more permanent solution can be found. I just upgraded my 1&1 hosting package to a newer server with same price which gives 60mb instead of 30mb. So let's see if that fixes things.