Email VPS
Troubleshooting and repair

Allowed memory size exhausted, how to fix running out of memory

Running out of memory in WordPress

Two errors often appear together. Allowed memory size of X bytes exhausted means the page needed more memory than it was given. Maximum execution time exceeded means the page needed more time. Both are symptoms of the same thing, something doing too much work during a single page load.

In short

  • Raising the limit is a temporary patch, not a fix.
  • The usual causes are a heavy plugin, an oversized image and an unbounded import.
  • If the limit is hit on the front page, this is about code rather than the server.

1. Look at where the error appears

Where the error showsWhat it tells you
When uploading an imageThe image is too large to process at the current memory limit
During an updateExtracting the package does not fit the limit
In an import or exportThe job is too big for one run and needs splitting
On an ordinary pageA plugin or theme does too much on every load

2. Raise the limit temporarily

The memory limit can be raised by adding define('WP_MEMORY_LIMIT', '256M'); to wp-config.php. This is the right move when you need the site open right now so you can get in and fix the actual cause. It is not a solution, because the limit returns as the site grows.

3. Find what eats the memory

Switch the plugins off and enable them one at a time, as described in our guide on a plugin that broke the site. Memory is typically consumed by page builders, multipurpose themes, statistics plugins that write every visit to the database, and backup plugins that compress the whole site mid visit.

4. Shrink the images

An image straight from a camera can be tens of megabytes, and WordPress then creates several sizes of it. Scale images to a sensible web size before uploading. This removes one of the most common causes entirely.

5. Split a large job

Imports, exports and bulk edits are better run in batches. Many tools offer batching out of the box, and it is almost always better than growing limits until one run fits.

6. If the symptom is slowness rather than a crash

Running out of memory and running out of time are the far end of the same phenomenon. If the site does not crash but is slow, start from our guide on why a WordPress site is slow. If a server error appears instead, see 502, 503 and 504.

What not to do

Do not raise the limit again and again without anyone looking at where the memory goes. That pushes the problem forward and makes it more expensive, because eventually you meet the real ceiling of the server rather than a setting.

If you would rather not do it yourself

We find what consumes the memory or the time and fix that, rather than simply raising the limit. We also tell you whether this is one plugin or a site that has outgrown its plan.

See how we repair a broken site »