Website Without PHP
English (United States)US
  • English (United States)
  • Dutch (Netherlands)
Menu

memory_limit

Also known as: PHP memory limit

memory_limit is a PHP setting that decides how much memory the code behind one page may use.

Read the explanation

More about this

If it needs more, it stops with an error.

PHP and versions Last updated:

memory_limit is a PHP setting that decides how much memory the code behind one page may use. If it needs more, it stops with an error. It protects a server from a single runaway script, and it is behind the well-known message “Allowed memory size exhausted”, which you may have seen on a broken page.

What is memory_limit?

Going over the limit stops the script with a fatal error.

Every request to your site starts a PHP script, and that script needs memory for the page, the plugins and the data it handles. memory_limit sets the ceiling. The built-in default is 128M, and many hosts choose their own value. It is set in php.ini, in a per-site settings file or in your hosting panel.

When a script hits the ceiling, PHP does not give it a bit more. It stops, and the visitor sees a blank page or a critical error. The cause is written to the error log as “Allowed memory size of N bytes exhausted”, with the file and line where it happened.

Limits in WordPress

WordPress has its own constants, WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT, which can raise the limit for the site and for the admin area. They only work if the host allows PHP to change the setting. If the server limit is lower and locked, the constants will not help.

memory_limit and your WordPress site

Which PHP version does your site report?

We read only what your site already sends in public: the headers and the top of the homepage. No scan, no login.

Memory errors tend to show up in the same places: importing a large file, generating image sizes, running a backup, loading a heavy page builder screen or running a WooCommerce report. After a plugin or PHP update they can also appear suddenly on a site that was fine before.

The trap is to raise the number every time. A limit that keeps going up hides a plugin that wastes memory, and it lets that plugin slow down the whole server.

How to find and fix the cause

Check the error log first. The message gives the limit that was hit and the file, and the file path usually points to the plugin or theme folder. If one WordPress plugin shows up again and again, that plugin is the first suspect.

Then look at the limit. If the site legitimately needs more, for example a large shop or an import, raise it in steps, such as from 128M to 256M, and test. Change it in the PHP settings of your hosting control panel or ask your host.

Avoid -1. Whatever value you choose, write down the old one first, so you can go back if the change causes trouble elsewhere on the server.

When to act

Act when the error appears more than once, or when it blocks something important, like checkout, login or the admin. If the site is already showing a critical error and you cannot get in to change anything, we can fix your WordPress website: we find the cause and restore the site.

Not sure how this applies to your site?

Ask a person to take a look. We check which PHP version your site runs and whether the fix is in, and tell you the next step.

Ask a person to take a look

Or have PHP updated right away: PHP update from $555 excl. VAT

Frequently asked questions

What does Allowed memory size exhausted mean?

A PHP script tried to use more memory than memory_limit allows, so PHP stopped it with a fatal error. The message includes the limit in bytes and the file where it happened.

What is the default memory_limit?

The built-in default of PHP is 128M. Your host may set a different value, so check the PHP settings of your site.

Should I set memory_limit to unlimited?

No. The value -1 removes the limit. A script with a bug can then use all memory on the server and take other sites down with it.

Raise the limit in steps instead.

Does raising memory_limit fix the real problem?

Not always. If one plugin uses far more memory than it should, a higher limit hides that. Find out which plugin or action triggers the error, and raise the limit if the work is legitimate.

Share this page

Ask your AI to explain

Opens the chat with a question about this page. An AI answer can differ; the sources above are leading.

This question is sent along: Summarise the confirmed facts on https://websitewithoutphp.com/en-us/glossary/memory-limit/ in 5 short points, with the source per point.

  1. Domain
  2. Check
  3. Result
  4. Report

Which PHP version does your site run?

Enter your domain. We read only what your site already sends in public: the headers and the top of the homepage. No scan, no login.

We keep the domain and the result, never your IP address.