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

PHP Memory Size: How do we decide the optimum size?

TheBigK

Well-known member
#1
Did a quick search on the forum; but could not find the exact information I'm looking for. Yesterday we ran into 'out of memory' errors; because PHP was consuming about 80 MB of data. It was because of an add-on.

I'm however curious to know what exactly should be our php memory setting? How do we decide it?
 

Mouth

Well-known member
#2
General rule is 96M for sites with image processing, and 128M for heavy php sites
Thus, 128M is my setting for XF
 

Mike

XenForo developer
Staff member
#9
The PHP default is 128M. There's very little reason to change that in general. XF will attempt to set the memory limit itself.
 

TheBigK

Well-known member
#10
The PHP default is 128M. There's very little reason to change that in general. XF will attempt to set the memory limit itself.
What's the best way to deal with php 'Out of Memory' errors? We got them on our site when the traffic spiked to about 6000 simultaneous users (~25 logged in members and rest all guests).
 

Mike

XenForo developer
Staff member
#11
Out of memory means that PHP couldn't allocate memory. Either you have an allocation limit smaller than PHP's limit or your server is out of memory (or couldn't allocate it for some reason).

Assuming it's a legit out of memory issue, the specifics of what to do vary a lot, but they do involve analyzing how much memory an active connection takes. If you can't reduce that (depending on configuration), you need to consider reducing the maximum number of active connections to prevent overloading the server or simply adding more memory.
 

RoldanLT

Well-known member
#12
What's the best way to deal with php 'Out of Memory' errors? We got them on our site when the traffic spiked to about 6000 simultaneous users (~25 logged in members and rest all guests).
If that's your situation, you have a lot of guest user's.
I highly recommend @xfrocks addon called BD Cache.
 

TheBigK

Well-known member
#13
If that's your situation, you have a lot of guest user's.
I highly recommend @xfrocks addon called BD Cache.
Well, I guess I had that add-on enabled when the downtime happened. It was @xfrocks who helped figuring out that 'Members Online Now' widget was responsible for eating up all the memory.

I think I've got a few leads to fixing this problem.
 

WSWD

Well-known member
#15
There is no magic number. Allocate as much as you possibly can. If you have 32GB of RAM, are you really going to allocate 128M or 256M to PHP? That's just plain silly. There's no optimum size, there's no general rule, there's no magic number.