Fixed Upgrading to 2.1: Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 167936 bytes)

entelechy

Member
When trying to upgrade to 2.1 I got this error at Step 12:

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 167936 bytes)

I vaguely understand it, but has anyone else encountered this and can advise on how to increase memory size allowed?
 

Chris D

XenForo developer
Staff member
Hmm. It's the first time we've seen this, but it could be related to the xf_error_log table and the fact that the field we're trying to change here may contain a significant amount of data in some cases.

You could increase the PHP memory_limit to account for this or what might be easiest is just to empty/truncate that specific table if you feel there's no information logged in there that you might need.
 

johnny82

Member
I faced the same error during a server migration a month ago, trying to set php 7.2 with xenforo 2.0.12 and I resolved using BassMan's hint, here, enabling PHP module nd_mysqli instead of mysqli.

That said, I don't know if it can be a solution for you too nor can I explain exactly why it resolved the issue in my case but you can give it a try..
 

entelechy

Member
Hmm. It's the first time we've seen this, but it could be related to the xf_error_log table and the fact that the field we're trying to change here may contain a significant amount of data in some cases.

You could increase the PHP memory_limit to account for this or what might be easiest is just to empty/truncate that specific table if you feel there's no information logged in there that you might need.
For future reference, deleting the server error log solved this issue immediately, thanks Chris
 

Nuno

Well-known member
I have the same error:

Code:
Server error log
ErrorException: Fatal Error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 139264 bytes) src/XF/Db/Mysqli/Statement.php:125
Generated by: Unknown account Mar 6, 2019 at 5:38 AM
Stack trace
#0 [internal function]: XF::handleFatalError()
#1 {main}
Request state
array(4) {
  ["url"] => string(8) "/job.php"
  ["referrer"] => string(92) "https://www.example.com/threads/abc.123/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
Using PHP 7.3.2 with XF21.

@Chris D should I truncate XF logs too?

Thanks
 

Chris D

XenForo developer
Staff member
Good to know but we should probably try to make changes here.

I think by default we try to fetch 2000 values at a time but the error log field we’re changing here may contain a significant amount of data (and that might apply to some other places) so we should try to reduce what we’re fetching in these cases.
 

Chris D

XenForo developer
Staff member
I have the same error:

Code:
Server error log
ErrorException: Fatal Error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 139264 bytes) src/XF/Db/Mysqli/Statement.php:125
Generated by: Unknown account Mar 6, 2019 at 5:38 AM
Stack trace
#0 [internal function]: XF::handleFatalError()
#1 {main}
Request state
array(4) {
  ["url"] => string(8) "/job.php"
  ["referrer"] => string(92) "https://www.example.com/threads/abc.123/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}
Using PHP 7.3.2 with XF21.

@Chris D should I truncate XF logs too?

Thanks
It won’t hurt.
 

XF Bug Bot

XenForo bug fixer bot
Staff member
Thank you for reporting this issue. It has now been resolved and we are aiming to include it in a future XF release (2.1.1).

Change log:
Support passing in a custom perPage value to entityColumnsToJson and tableColumnsToJson methods. Set XF:ErrorLog.request_state to do only 300 per page - this table's records are quite data heavy and has been seen to exhaust memory limits.
Any changes made as a result of this issue being resolved may not be rolled out here until later.
 

Chris D

XenForo developer
Staff member
Whatever that is, it can't be the same cause.

We don't even run any upgrade steps to upgrade from 2.1.0 to 2.1.1.
 
Top