1

My site's server logs show a repeating memory limit error:

[17-Jan-2013 17:26:01 UTC] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 523800 bytes) in /path/to/my/system/expressionengine/libraries/Template.php on line 894

As you can see, the server's memory limit is already set to 128 MB, so whatever template is causing this appears to be massive. Trouble is, I can't locate the problem template. Every page on my site is running well below 128 MB. Also, I haven't seen this PHP error anywhere on the front-end during development, and I assume it would appear if I tried to load the problem template.

Has anyone had this issue before? Is there a quirk or bug I'm not aware of that I should look for?

EE 2.5.5

EDIT
Line 894 in this file is:

$this->process_tags(); // Run the class/method handler
  • Please post line 894 from your Template.php file. – Anna_MediaGirl Jan 17 '13 at 18:57
  • Isn't the file the same for all EE installs? – kmgdev Jan 17 '13 at 18:58
  • The file is the same, but the code on line 894 may vary by EE version. Since you didn't note your EE version, best to post the code from that line of your actual file. Then we know what might be triggering the error. – Anna_MediaGirl Jan 17 '13 at 19:21
  • Gotcha. I updated the question with the EE version, since the line number occasionally changes from error to error (894 seems to be the most common, though). – kmgdev Jan 17 '13 at 19:40
1

The way I'd track this backwards is to look at access logs and match the line to the [17-Jan-2013 17:26:01 UTC] date/time. That should give you the URL accessed so you'll know which template is causing the problem.


EDIT:

You might also try refreshing the log file as you navigate the site. Load a page, then refresh the log... if the error is triggered and is showing in the logs, you know you've hit the problem template.

You can also install the EE Debug Toolbar so you can see page memory usage as you navigate the site.

| improve this answer | |
  • Sadly it's shared hosting and I don't have access to the Apache access logs. But good suggestion! – kmgdev Jan 17 '13 at 19:19
  • Can you ask your host to send you the lines from the logs right around this date/time? – Anna_MediaGirl Jan 17 '13 at 19:20
  • 1
    Many hosts will make the Apache logs available to you if you ask. They technically have to keep them separate for each account anyway. So frequently they will either temporarily give you the access to a file or just create a new folder to save the logs in, where you have regular access to them. – nonprofit_tech Jan 17 '13 at 19:25
  • I added a second option for troubleshooting in my answer. – Anna_MediaGirl Jan 17 '13 at 20:37
  • So I'm comparing the access logs with the error logs, but the timestamps don't match up - I'm assuming because the php error happens a few seconds after the initial http request? – kmgdev Feb 12 '13 at 21:21
3

I agree with @Anna_MediaGirl cross check you error logs with your access logs to see if you can identify the offending template.

You should note that some templates, let's say if you have a template using 'tags', can behave perfectly normal for regular use, but if a crawling bot hits them, may produce memory errors. This is because the bot keeps adding more and more tags, which a user probably wouldn't do. So the template may go from

http://mydomain.org/tags/tag/memory

to

http://mydomain.org/tags/tag/memory,php,error,user,etc.

We had to put in .htaccess blocks to this from happening, since the bots also didn't follow our robot.txt rules and not index the /tags/ area in the first place.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.