0

I have struggled with this for hours and days. I need good ideas for a fix now.

When I do a certain action in WordPress, I sometimes get a Fatal memory error. The error comes after I hit "Update" on a tag/term. The error seems to be related to a WordPress core file.

It looks like that the script hit a memory limit at around 700 MB: https://www.screencast.com/t/i6USBKHuWcxS

However, the limit on the server is much higher - 5096 MB: https://www.screencast.com/t/CyRJs8dohYYh

Our server administrator has confirmed that we do not hit any limit at their end.

What I have tried:

  • Deactivating all plugins and switch to default theme. That solves the problem
    • However: It is impossible to identify the problem to one single plugin. Different combinations of plugins gives the error.
  • Switching to PHP 7.1 solves the issue. However that's not a permanent, good solution.

Can there be a "fake" memory limit in some script, plugin etc.? We do use LiteSpeed Cache on the server - I do not know if that's relevant.

Any ideas and suggestions are appreciated.

2
  • PHP has a memory limit for the specific request, note that 700MB is very high. You can raise it via php.ini, but I would focus instead on lowering the memory footprint of your pages. Remember that web servers don't just handle a single request at a time, so if your page uses 5GB of memory and your server has 5GB, that means only one person can use the server at a time. It also takes time and resources to fill all that memory. Newer versions of PHP have smaller footprints and run faster, and PHP 7.1 is very old and unsupported – Tom J Nowell Jan 14 at 11:32
  • For reference, I've a local WP install here on PHP 7.3, its using 4MB of memory for each page request, my personal sites homepage uses 20MB, and a production site I'm working on is ~20MB. 700MB is larger than some Windows installers. Start by deactivating plugins. If no single specific plugin is responsible that doesn't mean you can't do anything, just like if you fill your shopping trolley till its overflowing you can still fix that, you don't need there to be a single item that fills half the trolley to fix it – Tom J Nowell Jan 14 at 11:39
1

A server has to serve lots of requests at the same time, and to prevent a PHP request running out of control it gives them 2 limits. Time, and memory. If it takes 2 hours to generate a page request, something has gone wrong.

If your request requires endless amounts of memory, something else has gone wrong. These problems can lead to resource exhaustion attacks and damage a sites ability to scale. The limits provide a safety net to prevent disaster, avoid infinite loops, catch bugs, etc.

Normally a good memory footprint for a WordPress site is under 100mb, ideally under 50mb. A vanilla WP install with no plugins and the default theme comes inn at ~4mb, and a lot of well built sites are ~20mb.

Anything above 100 is suspect, and 700mb is extremely high. Your site is either doing too much, doing things it does not need to do, or has bugs. This could be your theme, or a plugin, or a combination of several factors. It doesn't have to be 1 single thing, it can be lots of things piling up.

Newer versions of PHP will help mitigate the problem, but raising the memory limit in php.ini is only a stop-gap solution for most that doesn't fix the actual issue, which you have not found yet.

You need to grab a copy of your site, and attempt to profile it to get more information


The error seems to be related to a WordPress core file.

No, this is just what was happening when you ran out of memory.

A bit like the monty python scene where Mr Creosote has eaten everything in the restaurant and is offered a wafer thin mint, and explodes after eating it. It wasn't the mint that did it, it was the mountain of food. Likewise no individual piece of food was responsible, it was the combined bulk.

It looks like that the script hit a memory limit at around 700 MB:

700 is very high!

However: It is impossible to identify the problem to one single plugin. Different combinations of plugins gives the error.

You have too much stuff, get rid of some things or replace them with lighter less heavy things. Query Monitor can help you measure the memory used.

Switching to PHP 7.1 solves the issue. However that's not a permanent, good solution.

Actually this is a great move, but you did not go far enough. PHP 7.1 is old and unsupported, you should be on at least PHP v7.4 or newer.

However, the limit on the server is much higher - 5096 MB

You would never want a single request to actually use all of this.

2
  • Hi @Tom. Thanks for your reply. Regarding the PHP version: We are running 7.4 normally. So it actually helps switching to an older version. You write: "You need to grab a copy of your site, and attempt to profile it to get more information" - I have a copy of the install but how can I get more information? I have tried to switch plugins on and off but I cannot get further in the debugging. Do you have any tools or guides? – pstidsen Jan 14 at 16:28
  • just the standard debugging tools like xdebug and query monitor, recommendations are off topic here though, and your question is already on the extreme fringes of what this site allows since your Q needs to be specific and you don't actually know what the problem is, just that it causes high memory usage – Tom J Nowell Jan 14 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.