WordPress hit memory limit but not from the server

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.