Website Without PHP
US
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. If it needs more, it stops with an error.

PHP and versions Last updated:

memory_limit is a PHPPHP is a programming language that builds your web pages on the computer that hosts your site, just before they reach the visitor. WordPress runs on it. 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.iniphp.ini is the settings file for PHP on your hosting. It sets limits, such as how much memory a script may use, how big an upload may be and if errors show., in a per-site settings file or in your hostingWeb hosting is the service that keeps your website's files on a computer that is always online, so visitors can open your site at any time. 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 logAn error log is a file where your website's software writes down what went wrong, with the time and place. It is the first thing to check when a site breaks. as “Allowed memory size of N bytes exhausted”, with the file and line where it happened.

Limits in WordPress

WordPressWordPress is free software for building and editing a website in your browser. It is written in PHP, so it builds each page when someone visits. 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

Memory errors tend to show up in the same places: importing a large file, generating image sizes, running a backupA backup is a separate copy of your website's files and database, so you can bring the site back after a mistake, a hack or a failed update., loading a heavy page builderA page builder is a WordPress add-on, such as Elementor, that lets you design pages by dragging blocks around instead of working with code. screen or running a WooCommerceWooCommerce is a free add-on for WordPress that turns your website into a webshop, with products, a shopping cart and a checkout. 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 themeA WordPress theme is a ready-made package that decides how your WordPress site looks and how its pages are laid out. Change the theme and the design changes. folder. If one WordPress pluginA WordPress plugin is an add-on you install in WordPress to give your site extra features, such as contact forms, SEO tools or a webshop. 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 panelA hosting control panel, such as cPanel, Plesk or DirectAdmin, is the web page where you manage your domain, email, databases and PHP version. 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.

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.

Related pages

  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.