Rebuild XML Sitemap stops on Fatal error: Out of memory for Media Items

I'm trying to rebuild my sitemaps to include the XenForo Media Gallery content items.

When the rebuild gets to the 'XenForo Media Gallery: Media Items' part, it stops with this error:
Fatal error: Out of memory (allocated 77594624) (tried to allocate 65552 bytes) in /home/xx99/public_html/forums/library/Lgpl/utf8.php on line 378

If 'XenForo Media Gallery: Media Items' is the only content item NOT selected, the rebuild completes.
If it is the only item selected, it fails immediately.

PHP memory limit was set at 96M. I changed it to 256M and the error is exactly the same(same numbers).

Any thoughts on troubleshooting this?


Chris D

XenForo developer
Staff member
PHP memory limit was set at 96M. I changed it to 256M and the error is exactly the same(same numbers).
This is the problem.

Did you restart your web server/PHP after changing the limit? What is the web server? Apache or something else?

The error indicates that the memory limit is actually around ~77MB so something else is overriding it. It's worth noting that XenForo tries to set the limit to a minimum of 128MB at run time, so that isn't working either.

Once the memory limit problem has been solved, the problem should be solved.
I did not restart. The web server is Litespeed.
For lsphp5 I see Memory Soft Limit (bytes) 450M, Memory Hard Limit (bytes) 500M
I will try restarting Litespeed, but it sounds like I need to look somewhere else for the limit.

Anywhere else I can look for that limit?

Chris D

XenForo developer
Staff member
A restart would be required for the new values to take effect in most cases, but it is still somewhat suspicious that the limit is being reported lower than what it has been set to.

Chris D

XenForo developer
Staff member
There is another possibility; what's the physical memory usage like on the server? Are you actually running out of RAM?

Chris D

XenForo developer
Staff member
Looks like you're getting 4GB and using it and not a drop more, hence the error.

Earlier when the error stated out of memory and it was about 77MB it looks like you were already using over 3.9GB.

You either need more RAM or to cut down your resource usage. Your host will be best placed to advise on this.


XenForo developer
Staff member
There should be enough RAM because the buffers will be cleared if needed (free is really free + buffers).

However, Chris is right in that PHP is simply dying because it can't allocate memory so it's not memory_limit related. Usually this is something that has to be explicitly configured, but unfortunately I'm not sure where; it would usually be controlled by whatever system is spawning PHP via a ulimit. It certainly sounds like the config you found is relevant, but clearly the values are much higher than what's triggering here, but you try increasing it further.
Contacted the host and they tried a number of things.
What worked was changing
xcache.size => 64M => 64M and setting it to 160M

The sitemap rebuild completed, but I got a few of these errors in the server error log
"ErrorException: Fatal Error: XCache: Cannot init - Unknown:0"

I don't have Xcache or any cache set up in the config file.
Does any of that make sense?