WordPress Memory Limit and max_input_vars: How to Fix Memory Errors and Menus That Do Not Save
“Allowed memory size exhausted” or menu items that vanish on save? What the PHP limits do, how to read the error, and where to raise each value.
On this page 10 sections
Two PHP limits are behind a large share of WordPress errors. The memory limit sets how much memory one page request may use: when it is too low you get “Allowed memory size of … bytes exhausted” or a white screen. The max_input_vars limit sets how many form fields PHP accepts in one request: when it is too low, large menus and settings pages quietly lose part of what you save. For a WooCommerce store, set the memory limit to 256M and max_input_vars to 3000 or more.
This guide explains what each limit does, how to read the error, where to change the values, and what to do when raising them does not help.
We build WooCommerce themes at 8theme. Memory limit errors come up in about 830 of the 45,000+ topics in our support forum and max_input_vars in about 370 (counted in November 2026). Most of them end with one of the changes below.
The PHP limits that matter
| Limit | What it controls | What you see when it is too low |
|---|---|---|
| memory_limit | Memory for one page request | “Allowed memory size exhausted”, a white screen, a failed import or update |
| max_input_vars | Number of form fields in one request | Menu items that disappear after saving, theme options or variations that do not save |
| max_execution_time | Seconds a request may run | Imports and updates that stop halfway, a 504 error |
| upload_max_filesize and post_max_size | Size of an uploaded file | “The uploaded file exceeds the upload_max_filesize directive” |
How to check the current values
- Tools → Site Health → Info → Server lists the PHP memory limit, the time limit, max input variables and the upload size.
- WooCommerce → Status shows the same values and marks the ones that are too low.
- In XStore, the System Requirements tab of the XStore Control Panel compares your server with what the theme needs.
How to read the memory error
The message looks like this:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /wp-content/plugins/example/file.php on line 120
The first number is your current limit in bytes.
| Bytes in the message | Limit |
|---|---|
| 41943040 | 40M |
| 67108864 | 64M |
| 134217728 | 128M |
| 268435456 | 256M |
| 536870912 | 512M |
The file named at the end is where PHP ran out of memory. It is a hint, not a verdict: the plugin that used most of the memory may be a different one.
How to raise the memory limit
Try these in order and stop at the first one that works.
1. In wp-config.php. Add this line above the comment that says to stop editing:
define( 'WP_MEMORY_LIMIT', '256M' );
2. In the hosting panel. Most panels have a PHP settings page, often called PHP options, PHP selector or MultiPHP INI Editor. Set memory_limit there.
3. In php.ini or .user.ini in the site’s root folder:
memory_limit = 256M
4. Ask the host. On many shared plans the limit is fixed by the plan, and the lines above change nothing. The host can raise it or tell you the maximum.
WordPress cannot give itself more memory than the server allows. If Site Health still shows the old value after your change, the server’s own limit is lower.
How to raise max_input_vars
This limit cannot be changed in wp-config.php. Use one of these:
- The hosting panel: set max_input_vars on the PHP settings page.
- php.ini or .user.ini:
max_input_vars = 3000
- .htaccess, only on servers that run PHP as an Apache module:
php_value max_input_vars 3000
If the site answers with a 500 error after the .htaccess change, remove the line: the server does not accept it there.
How to raise max_execution_time
The time limit stops a request that runs too long. Imports, demo installs and updates meet it first: the job stops halfway, or the page ends with a 504 error.
- The hosting panel: set max_execution_time to 120 to 300 seconds on the PHP settings page.
- php.ini or .user.ini:
max_execution_time = 300
- .htaccess, on servers that run PHP as an Apache module:
php_value max_execution_time 300
The web server and a CDN in front of the site have their own time limits, and PHP cannot raise those. For a job that needs many minutes, such as a very large import, split it into parts or ask the host to run it from the command line.
Why menu items disappear
Every menu item sends about a dozen form fields when the menu is saved. With the default limit of 1000, WordPress receives only the first 80 to 90 items and drops the rest without a warning. Mega menus fill the limit even sooner, because each item carries extra settings.
Raise max_input_vars, then add the lost items again. They were not saved, so they cannot be recovered.
The same limit is behind theme options that will not save, products whose variations vanish after an update, and long forms in page builders.
What XStore asks for
The XStore requirements list these minimums: a memory limit of 128M, max_input_vars of 1000 to 2000, a max execution time of 120 to 180 seconds and an upload size of 10M. They are the floor for installing the theme and importing a demo. A store with a page builder, WooCommerce and a dozen plugins is more comfortable with 256M and 3000.
When raising the limit does not help
- The error returns at a higher number. Something uses memory without end: a plugin stuck in a loop, or an import that loads everything at once. Deactivate plugins one at a time to find it.
- It happens only on one screen. That screen’s plugin is the suspect: a page with thousands of orders, a report, a large export.
- It started after an update. Roll that plugin back on a staging copy and report the error to its author.
- The PHP version is old. Newer PHP versions use less memory for the same work.
A limit of 512M or more hides a problem, it does not fix it. If a normal page needs that much, look for the cause.
FAQ
What should the WordPress memory limit be?
256M is a sound value for a WooCommerce store. 128M is enough for a small site with few plugins. More than 512M usually means something is wrong.
What does “Allowed memory size of 134217728 bytes exhausted” mean?
A page request needed more than 128M of memory, the current limit, and PHP stopped it. Raise the limit to 256M, and if the error comes back, find the plugin that uses the memory.
Why do my menu items disappear when I save the menu?
The menu sends more form fields than max_input_vars allows, and PHP drops the rest. Raise max_input_vars to 3000 or more and add the items again.
Can I change max_input_vars in wp-config.php?
No. It is read before WordPress starts. Change it in the hosting panel, in php.ini or .user.ini, or ask the host.
What limits does XStore need?
XStore by 8theme lists a 128M memory limit, max_input_vars of 1000 to 2000 and a max execution time of 120 to 180 seconds as minimums. For a working store we suggest 256M and 3000.
Does a higher memory limit make the site faster?
No. The limit is a ceiling, not a speed setting. A page that needs 60M runs the same with a 128M limit and with a 512M one.















