XF 2.1 Fatal error: Allowed memory size exhausted

Joe Link

Well-known member
I've been getting these errors when trying to edit templates since upgrading to 2.1.8 P2 yesterday. Not always, but frequently.

Any ideas?

Code:
Fatal error: Allowed memory size of 335544320 bytes exhausted (tried to allocate 86016 bytes) in /home/domain.com/public/src/XF/Db/Mysqli/Statement.php on line 125

Fatal error: Allowed memory size of 335544320 bytes exhausted (tried to allocate 65536 bytes) in /home/domain.com/public/src/vendor/league/flysystem/src/Adapter/Local.php on line 489
 

Joe Link

Well-known member
Here's the only thing in the PHP error log...

Code:
[27-Mar-2020 16:07:03 UTC] PHP Fatal error:  Allowed memory size of 335544320 bytes exhausted (tried to allocate 90112 bytes) in /home/domain.com/public/src/XF/Db/Mysqli/Statement.php on line 125
[27-Mar-2020 16:07:03 UTC] PHP Fatal error:  Allowed memory size of 335544320 bytes exhausted (tried to allocate 65536 bytes) in /home/domain.com/public/src/vendor/league/flysystem/src/Adapter/Local.php on line 489
[27-Mar-2020 16:13:59 UTC] PHP Fatal error:  Allowed memory size of 335544320 bytes exhausted (tried to allocate 86016 bytes) in /home/domain.com/public/src/XF/Db/Mysqli/Statement.php on line 125
[27-Mar-2020 16:13:59 UTC] PHP Fatal error:  Allowed memory size of 335544320 bytes exhausted (tried to allocate 65536 bytes) in /home/domain.com/public/src/vendor/league/flysystem/src/Adapter/Local.php on line 489
[27-Mar-2020 16:14:31 UTC] PHP Fatal error:  Allowed memory size of 335544320 bytes exhausted (tried to allocate 86016 bytes) in /home/domain.com/public/src/XF/Db/Mysqli/Statement.php on line 125
[27-Mar-2020 16:14:31 UTC] PHP Fatal error:  Allowed memory size of 335544320 bytes exhausted (tried to allocate 65536 bytes) in /home/domain.com/public/src/vendor/league/flysystem/src/Adapter/Local.php on line 489
[27-Mar-2020 16:21:15 UTC] PHP Fatal error:  Allowed memory size of 335544320 bytes exhausted (tried to allocate 86016 bytes) in /home/domain.com/public/src/XF/Db/Mysqli/Statement.php on line 125
[27-Mar-2020 16:21:15 UTC] PHP Fatal error:  Allowed memory size of 335544320 bytes exhausted (tried to allocate 65536 bytes) in /home/domain.com/public/src/vendor/league/flysystem/src/Adapter/Local.php on line 489
 

Joe Link

Well-known member
Interesting! Thanks for finding that.

My PHP memory limit is set to 320MB. This only seems to happen when I try to open a large .less template. Seems about 50/50 as to whether I'll get the error or the template will open properly.
 

Chris D

XenForo developer
Staff member
If this developed suddenly it's highly unlikely to be related to 2.1.8 and more likely related to a change within your installation or on the server itself.

If this is being triggered only by template edits then we'd likely need more details such as which templates, what their current contents are, what you're trying to change them to.

This is a process that should not be using in excess of 300MB of memory so something unexpected is happening.
 

Joe Link

Well-known member
Thanks for the reply, Chris.

It's really odd. It's happening on our dev server, and the only changes we've made were the updates of XF, XFMG, and XFES. If I copy the .less template to our production server which is still on 2.1.7 there's no issue (refreshed ~50 times to make sure).

Should I open a ticket?
 

Joe Link

Well-known member
Another possible clue, when I disable all addons and try it I get a plain white screen (literally no HTML source) with about the same frequency that I got the errors (50/50).
 

Joe Link

Well-known member
It's possible but unlikely. We try to keep the two environments as close as possible to detect any issues before pushing them to production. Just verified they're both using the same versions of PHP (7.3.16), MySQL (10.3.22-MariaDB), NGINX (1.17.9).
 

Joe Link

Well-known member
When I disabled/enabled all the add-ons a few of these were logged in the AdminCP.

Code:
Server error log

    ErrorException: Fatal Error: Allowed memory size of 335544320 bytes exhausted (tried to allocate 90112 bytes) src/XF/Db/Mysqli/Statement.php:125

    Generated by: Joe Link Mar 27, 2020 at 10:12 AM

Stack trace

#0 [internal function]: XF::handleFatalError()
#1 {main}

Request state

array(4) {
  ["url"] => string(58) "/admin.php?templates/global-less.1497/edit&style_id=4"
  ["referrer"] => string(81) "https://domain.com/admin.php?styles/global.4/templates&type=public"
  ["_GET"] => array(2) {
    ["templates/global-less_1497/edit"] => string(0) ""
    ["style_id"] => string(1) "4"
  }
  ["_POST"] => array(0) {
  }
}
 

Ludachris

Well-known member
When I disabled/enabled all the add-ons a few of these were logged in the AdminCP.

Code:
Server error log

    ErrorException: Fatal Error: Allowed memory size of 335544320 bytes exhausted (tried to allocate 90112 bytes) src/XF/Db/Mysqli/Statement.php:125

    Generated by: Joe Link Mar 27, 2020 at 10:12 AM

Stack trace

#0 [internal function]: XF::handleFatalError()
#1 {main}

Request state

array(4) {
  ["url"] => string(58) "/admin.php?templates/global-less.1497/edit&style_id=4"
  ["referrer"] => string(81) "https://domain.com/admin.php?styles/global.4/templates&type=public"
  ["_GET"] => array(2) {
    ["templates/global-less_1497/edit"] => string(0) ""
    ["style_id"] => string(1) "4"
  }
  ["_POST"] => array(0) {
  }
}
@Joe Link - did you ever get the cause identified for this? I'm having this happen on one of my forums after upgrading from 1.5 to 2.2.
 

Joe Link

Well-known member
@Joe Link - did you ever get the cause identified for this? I'm having this happen on one of my forums after upgrading from 1.5 to 2.2.

I did for a while, but it's back now, and I can't for the life of me remember how I fixed it before. I want to say it had to do with PHP memory settings...

I'll continue to look for my notes and report back if I find them.
 

Ludachris

Well-known member
I did for a while, but it's back now, and I can't for the life of me remember how I fixed it before. I want to say it had to do with PHP memory settings...

I'll continue to look for my notes and report back if I find them.
Let me know what you find. I have memory_limit set to 1024M. You'd think that would be enough.
 
Top