• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.5 Fatal Error: Allowed memory size of 671088640 bytes exhausted (tried to allocate 786432 bytes)

#1
How can I track down what's causing this? It happens over a dozen times a day, usually when users are viewing nodes or the front page.

Code:
Server Error Log
Error Info
ErrorException: Fatal Error: Allowed memory size of 671088640 bytes exhausted (tried to allocate 786432 bytes) - library/XenForo/Template/Abstract.php(265) : eval()'d code:1752
Generated By: Unknown Account, 54 minutes ago
Stack Trace
#0 [internal function]: XenForo_Application::handleFatalError()
#1 {main}
Request State
array(3) {
  ["url"] => string(33) "https://myforum.com/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
 

Mike

XenForo developer
Staff member
#3
Unfortunately, this is difficult to debug unless you can reproduce it with consistency. I'd have to guess this is add-on related, though it could also be related to your custom style. Debugging may require disabling add-ons one-by-one to see if/when the errors stop.
 
#4
PHP memory issues, have you tried increasing the available memory for php in the config (of php)
Seems dubious. There shouldn't be any reason for the forum to be sucking up 700 MB of RAM to show a node list.

Unfortunately, this is difficult to debug unless you can reproduce it with consistency. I'd have to guess this is add-on related, though it could also be related to your custom style. Debugging may require disabling add-ons one-by-one to see if/when the errors stop.
Disabling add-ons one-by-one seems a bit prone to error.. any other ideas, since you said "may require"? I'm quite comfortable with the shell; I just don't know my way around PHP.
 

xenfans

Well-known member
#9
640 MB AKA 671088640 bytes.
Just saying, it can be set to 32M and still report that 640M has been exhausted. As per many Google results.
It's local value is not being overwritten by say Apache as a master value (or something like that)? Try force overwriting it by updating .htaccess with something like php_value memory_limit 1024M or whatever you think is reasonable to use.
In the CLI you can find the .log files under /var/log usually, perhaps you can use: tail -F file.log
and run the frontpage of the forum and see where it runs into the error specifically. You could also try running the site in debug mode and load the ?debug=1 in the url and see when it errors, if it discloses where it errors on that page if you get lucky.

Try reproducing it with turning off some add-ons from the admin.php > list of add-ons, that aren't really essential to the site and see if you can reproduce the issue, perhaps try making a default theme and run that, see if it fixes it.

It seems to occur when xenforo throws stuff through eval(); so perhaps it's trying to cache templates to the disk, or one of those sort of situations (maybe mike can tell us which obvious cases uses eval)
 
#10
It's local value is not being overwritten by say Apache as a master value (or something like that)? Try force overwriting it by updating .htaccess with something like php_value memory_limit 1024M or whatever you think is reasonable to use.
It's not in nginx (I don't use apache). AFAIK nginx doesn't affect it like Apache does.

In the CLI you can find the .log files under /var/log usually, perhaps you can use: tail -F file.log
Happen to know what the log is called? Nothing stands out as being xenforo-related.

and run the frontpage of the forum and see where it runs into the error specifically. You could also try running the site in debug mode and load the ?debug=1 in the url and see when it errors, if it discloses where it errors on that page if you get lucky.
Tried that, the error is very intermittent and I couldn't get it after 100 refreshes... but we have an average of 300-400 users on at a time, so it's fairly common for a user to see it, I'm guessing.
 

Mike

XenForo developer
Staff member
#11
It is in a template, so serving the templates from files may help pinpoint it a little bit more (the template itself and then tracing into the actual compiled line), but the problem is that the issue may not be with the line in question -- that's just what's tipping it over, so it could be something earlier using a huge amount of memory. That said, it's trying to allocate over 700k here, so that would imply it has a large chunk of data involved on this line.
 
#12
It is in a template, so serving the templates from files may help pinpoint it a little bit more (the template itself and then tracing into the actual compiled line), but the problem is that the issue may not be with the line in question -- that's just what's tipping it over, so it could be something earlier using a huge amount of memory. That said, it's trying to allocate over 700k here, so that would imply it has a large chunk of data involved on this line.
I gave that a shot, took a while for the error to show up, but had no more information than before... unless you meant to look for the actual compiled line, which I realize now you just said! Where could I find the file for the template in question?

That said, it's trying to allocate over 700k here, so that would imply it has a large chunk of data involved on this line.
Just to make sure I'm not misunderstanding the nature of the error -- isn't this actually trying to allocate over 640 MB? If it's actually 700k and there's a problem in my memory settings, I'm not too worried about it...
 
#13
Actually, it was slightly different:

Code:
Server Error Log
Error Info
ErrorException: Fatal Error: Allowed memory size of 671088640 bytes exhausted (tried to allocate 72 bytes) - library/XenForo/Template/Abstract.php:591
Generated By: trombone, Today at 3:19 AM
Stack Trace
#0 [internal function]: XenForo_Application::handleFatalError()
#1 {main}
Request State
array(3) {
  ["url"] => string(33) "https://myforum.com/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
 

Mike

XenForo developer
Staff member
#14
Just to make sure I'm not misunderstanding the nature of the error -- isn't this actually trying to allocate over 640 MB? If it's actually 700k and there's a problem in my memory settings, I'm not too worried about it...
The example in question was a failed allocation of over 700KB of memory due to hitting the memory limit. That's what I meant by the "tipping over" comment.

The new backtrace is actually a really good example: it's a 72 byte allocation that triggered the limit. We unfortunately won't have any clue where the other 640MB of memory went. And given that there's no obvious reproduction case, that will make debugging this virtually impossible unfortunately. Because PHP doesn't give very useful error messages here, it really needs something to allow it to be triggered consistently so it can be worked through methodically.
 
#15
The example in question was a failed allocation of over 700KB of memory due to hitting the memory limit. That's what I meant by the "tipping over" comment.

The new backtrace is actually a really good example: it's a 72 byte allocation that triggered the limit. We unfortunately won't have any clue where the other 640MB of memory went. And given that there's no obvious reproduction case, that will make debugging this virtually impossible unfortunately. Because PHP doesn't give very useful error messages here, it really needs something to allow it to be triggered consistently so it can be worked through methodically.
I actually found a user who triggers this every time he tries to log in... any ideas about things I can do? Thinking about enabling debug mode and logging in as him.
 
#16
Turning debug mode on, sadly, just gave the same output as what was logged in the admin panel.

Tried increasing the memory limit, and interestingly enough, it went over by the same amount both times.

Before:

Code:
Server Error Log
Error Info
ErrorException: Fatal Error: Allowed memory size of 671088640 bytes exhausted (tried to allocate 786432 bytes) - library/XenForo/Template/Abstract.php(265) : eval()'d code:1752
Generated By: a user, 6 minutes ago
Stack Trace
#0 [internal function]: XenForo_Application::handleFatalError()
#1 {main}
Request State
array(3) {
  ["url"] => string(33) "https://forum.replica-watch.info/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
After:

Code:
Server Error Log
Error Info
ErrorException: Fatal Error: Allowed memory size of 713031680 bytes exhausted (tried to allocate 786432 bytes) - library/XenForo/Template/Abstract.php(265) : eval()'d code:1752
Generated By: a user, 2 minutes ago
Stack Trace
#0 [internal function]: XenForo_Application::handleFatalError()
#1 {main}
Request State
array(3) {
  ["url"] => string(33) "https://forum.replica-watch.info/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
Notice that both tried to allocate 786432 bytes despite the limit being higher...
 

Mike

XenForo developer
Staff member
#17
If you turn on templates as files, can you get that error within the template?

It certainly looks like some sort of huge/infinite loop in a template.