WordPress, plugins, and themes require memory during execution. How much memory a PHP process is allowed to use is limited, among other things, by the PHP memory limit.
If the available memory is not sufficient for a specific request, WordPress cannot complete the processing successfully. The consequences range from a failed action to a critical error, a white screen, or an HTTP 500 error.
A typical error message contains:
Allowed memory size ... exhausted
A higher memory limit can solve a real memory problem. However, it is not always the correct permanent solution. If a faulty plugin consumes an unusual amount of memory, a higher limit may merely postpone the point at which the error occurs.
Briefly explained: The PHP memory limit determines how much memory PHP is allowed to use during execution. WordPress also has its own constants like
WP_MEMORY_LIMITandWP_MAX_MEMORY_LIMIT. These values must be considered in the context of the PHP limit actually allowed by the server. Furthermore, more memory does not automatically make WordPress faster.
What is the PHP memory limit? #
The PHP memory limit is a restriction on the amount of memory that a PHP process or a PHP script may use during its execution.
The underlying PHP setting is called:
memory_limit
WordPress itself, plugins, themes, and custom PHP code share the available memory within that execution during a WordPress request.
If processing requires more memory than allowed, PHP terminates the execution in question with an error.
PHP memory limit is not the total RAM of the server #
The PHP memory limit must not be confused with the total physical RAM of a server or hosting account.
A value like:
memory_limit = 256M
does not mean that the entire server only has 256 MB of RAM.
Likewise, it does not mean that WordPress permanently uses 256 MB of memory. The value defines an upper limit for the respective PHP execution within the applicable PHP configuration.
Why does WordPress need memory? #
During a dynamic request, WordPress loads the core, processes configurations, initializes plugins and the theme, executes functions, processes data, and finally generates a response.
All these processes require memory.
How much memory is actually used depends heavily on the respective request. A simple public content page can require significantly less than an extensive import, image processing, or a complex WooCommerce process.
What happens when the memory limit is reached? #
If PHP requires additional memory during execution and would thereby exceed the allowed limit, processing can be terminated with a fatal error.
A typical message looks something like this:
PHP Fatal error: Allowed memory size of ... bytes exhausted
Often the message also contains information about how many bytes PHP still wanted to allocate and in which file the error became apparent.
The file in the error message is not automatically the cause #
This point is particularly important for the diagnosis.
If the memory error mentions a file path within a plugin, this plugin may be involved in the cause. However, the file path alone does not always prove this.
The memory may have already been largely consumed by previously executed code. The error then occurs where PHP attempts to request the next memory area.
Therefore, a memory error should be investigated in the context of the entire request and further log entries.
Important: The last file in a
Allowed memory size exhausted-Error is not necessarily the component that caused the entire memory consumption.
Typical symptoms of a memory limit that is too low #
A memory issue does not have to occur on every page.
The public frontend might work without any issues, while a specific action in the WordPress admin area fails. In other cases, the error only occurs when importing large amounts of data, editing a complex layout, or during specific WooCommerce processes.
In severe cases, WordPress may display a critical error or terminate the request with HTTP 500.
Why does the error sometimes only occur in the admin area? #
Administrative processes can perform different or more extensive functions than normal page views.
A page builder, an import plugin, WooCommerce, a backup process, or media processing can require significantly more memory in the admin area than a simple public page.
Additionally, WordPress distinguishes between the normal memory limit and a higher memory requirement for certain administrative tasks.
Therefore, several memory values must be kept separate in WordPress.
PHP memory_limit, WP_MEMORY_LIMIT, and WP_MAX_MEMORY_LIMIT #
When it comes to WordPress memory, three different values are often confused with one another.
The PHP setting:
memory_limit
belongs to the PHP runtime environment.
WordPress also knows the constants:
WP_MEMORY_LIMIT
and
WP_MAX_MEMORY_LIMIT
These values have different functions and should not simply be regarded as three names for the same setting.
What does WP_MEMORY_LIMIT do? #
WP_MEMORY_LIMIT defines the memory limit that WordPress attempts to allocate for normal WordPress executions.
The constant can be in:
wp-config.php
be defined.
An example would be:
define( 'WP_MEMORY_LIMIT', '256M' );
However, that does not automatically mean that PHP or the hosting server actually provides WordPress with 256 MB.
What does WP_MAX_MEMORY_LIMIT do? #
For certain administrative operations, WordPress can use a higher memory limit.
There is for this:
WP_MAX_MEMORY_LIMIT
An example would be:
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
Even this value cannot arbitrarily override the technical limits of the PHP or hosting configuration.
WordPress cannot arbitrarily override the server-side maximum #
This is one of the most common misconceptions on this subject.
Assuming the hosting environment allows a maximum of:
memory_limit = 256M
and in wp-config.php will be entered:
define( 'WP_MEMORY_LIMIT', '1024M' );
Then this entry does not automatically mean that WordPress can actually use 1 GB.
Whether and up to what value PHP is allowed to change the memory limit at runtime depends on the PHP and server configuration.
Note: A high value in
wp-config.phpguarantees that there is no correspondingly high, actually available PHP memory.
What memory limit does WordPress actually use? #
For a reliable diagnosis, you should not rely exclusively on a single value from a configuration file.
WordPress displays server environment information in the admin area under:
Tools → Website health → Report
Depending on the installation and environment, relevant PHP and WordPress values can be checked there.
In the event of technical problems, PHP information or the hosting administration can also show which server-side memory_limit is actually active.
Why different ads can show different values #
If a WordPress plugin shows a different memory value than the hosting panel, it does not necessarily mean that one of the displays is wrong.
Different levels may be represented: the PHP configuration, a limit set by WordPress, or a value for a specific execution context.
Different PHP versions or configurations for web requests and command-line processes can also play a role.
What should the PHP memory limit be for WordPress? #
There is no single value that is optimal for every WordPress website.
A small business website with few extensions requires different resources than an extensive WooCommerce store, a page builder with complex layouts, or a website with large import and export processes.
Therefore, the memory limit should be sufficiently high for the legitimate requirements of the website, but should not serve as a substitute for analyzing unusually high memory consumption.
Is 128 MB enough? #
For simple WordPress installations, such a value may be sufficient depending on the components used.
However, more memory may be required for more extensive plugins, page builders, or administrative processes.
Therefore, the number alone does not allow for a reliable assessment of the quality of a hosting environment.
Are 256 MB or 512 MB better? #
A higher limit provides more headroom for memory-intensive processes.
If a legitimate WordPress function requires 180 MB, for example, a 128 MB limit would fail, while 256 MB might be sufficient.
If, on the other hand, a faulty process requires more and more memory due to an infinite loop, a limit of 512 MB or more will eventually be reached.
Therefore, the correct question is not just „What is the limit?“, but also „Why does this process require so much memory?“
More memory doesn't automatically make WordPress faster #
The PHP memory limit is primarily an upper limit and not a performance dial.
For example, if a WordPress request requires 80 MB and has 256 MB available, it generally won't run any faster just because the limit is increased to 512 MB.
More available memory helps when a legitimate process fails at the previous limit. However, it does not automatically speed up PHP, database queries, or the frontend.
Therefore, in case of general performance issues, you should investigate the actual causes. You can find our article on this here WordPress is slow: Finding causes and improving loading time.
Why plugins can consume a lot of memory #
Plugins can load or process large amounts of data during a request.
This affects, for example, imports, exports, statistics, search functions, backups, security scans, or complex data processing.
Therefore, a high memory requirement does not automatically have to be a programming error.
However, if an extension suddenly requires significantly more memory than before during normal operations, it should be investigated what has changed.
Plugin conflicts and memory usage #
An interaction between multiple extensions can also increase resource consumption.
When a memory error starts immediately after the installation or update of a plugin, the temporal connection is an important clue.
We explain how to examine extensions in a controlled manner at Identifying and Resolving Plugin or Theme Conflicts in WordPress.
Page Builder and complex pages #
Page builders sometimes have to process extensive page structures, widgets, and settings during editing.
Therefore, a very complex page can require significantly more PHP memory in the editor than the public output of the same page.
If only the editor of a certain large page crashes with a memory error, the complexity of that page should therefore also be taken into account.
WooCommerce can cause higher memory usage #
WooCommerce expands WordPress with extensive shop functions. Additional extensions for payments, shipping, invoices, product filters, or inventory management increase the complexity even further.
Especially imports, exports, reports, or extensive administrative processes may require more memory than a standard content page.
Therefore, a higher memory requirement for a shop is not unusual. Nevertheless, a sudden and sharp increase in consumption should be investigated.
Image editing can require a lot of memory #
When uploading images, WordPress must generate different image sizes depending on the configuration.
The required RAM does not depend exclusively on the image file size.
For example, a heavily compressed JPEG can be only a few megabytes in size, but require significantly more memory after being decompressed in RAM.
Very large image dimensions can therefore lead to memory problems during server-side image processing.
Backups and archives #
Backup plugins can process large amounts of files and data.
Depending on the implementation, this can result in considerable memory requirements.
If a memory error occurs exclusively during a backup, the backup process should therefore be investigated first, instead of massively increasing the memory limit across the board for the entire website.
Import and Export #
Large XML, CSV, or other import files can be memory-intensive if an extension loads too much data into memory at once.
Well-developed import processes often break down large amounts of data into smaller processing steps.
If an import reproducibly fails at a specific amount of data, the method of operation of the import plugin used can therefore be relevant in addition to the memory limit.
PHP version and memory limit are separate issues #
The PHP version used and the memory limit both belong to the PHP environment, but they are not the same thing.
Switching to a newer PHP version does not automatically mean that WordPress gets a higher memory limit.
Likewise, a higher memory limit does not fix incompatibility with a specific PHP version.
If an error started after changing the PHP version, you can find the appropriate diagnosis under Change PHP version for WordPress and check compatibility.
Memory error after a plugin update #
If a website worked without any issues before a plugin update and memory errors occur immediately afterward, the update in question should be investigated more closely.
Perhaps the new version runs additional processes, a bug creates a loop, or a new feature actually requires more memory.
The first step should not automatically be to keep increasing the limit.
Memory error after a WordPress update #
Even after a WordPress core update, a previously hidden problem can become visible.
That does not automatically mean that WordPress itself requires too much memory.
For example, a plugin or theme may react differently with the new WordPress version and thus cause the error.
Memory error after a theme change #
Comprehensive themes can load additional frameworks, page builder components, and features.
If a memory problem begins immediately after a theme change, the theme should therefore also be considered as a possible cause.
When using a child theme, individual customizations are also part of the diagnosis.
HTTP 500 due to exhausted PHP memory #
A memory error may manifest to the visitor as an HTTP 500 error.
The visible error message in the browser may then not reveal that the memory limit is the actual cause.
That is why error logs are especially valuable when dealing with an HTTP 500 error.
You can find further potential causes under How to fix WordPress error 500.
Critical WordPress error due to lack of memory #
A fatal PHP error due to exhausted memory can also trigger the WordPress critical error message.
When WordPress Recovery Mode is available, it can help restore access to the admin area in the event of certain fatal errors.
You can find the general procedure under WordPress shows a white screen or a critical error: What to do?.
Find memory errors in the error log #
If the website only shows a general error message, you should check the server or PHP error logs.
A relevant entry typically contains:
Allowed memory size
and
exhausted
The timestamp should match the time of the failed page view or process.
Use WordPress debugging for diagnosis #
In addition to server-side error logs, WordPress can log its own debug information.
Relevant constants are:
WP_DEBUG
WP_DEBUG_LOG
WP_DEBUG_DISPLAY
How to use these settings in a controlled manner is covered in the article Enable WordPress debugging and use error logs.
Attention: Detailed PHP errors should not be permanently displayed publicly on a production website. Error logs can contain technical and potentially sensitive information.
Change Memory Limit in wp-config.php #
WordPress-specific memory values can in certain environments via:
wp-config.php
be defined.
For example:
define( 'WP_MEMORY_LIMIT', '256M' );
or for certain administrative processes:
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
These values should not be defined multiple times with different information in the same configuration.
Furthermore, it still applies: WordPress cannot use this to arbitrarily exceed a server-defined maximum.
Where does the setting go in wp-config.php? #
When you manually define a WordPress constant, it should be within the configuration area of:
wp-config.php
stand and be loaded before WordPress is fully initialized.
Only edit the file if you are familiar with its function and create a backup beforehand.
Change PHP memory_limit via the hosting environment #
Whether you actually PHP-memory_limit can change yourself depends on the hosting configuration.
Modern hosting systems can provide PHP settings via a control panel.
In other environments, the maximum available value is specified on the server side.
If a change in the WordPress code has no effect, you should therefore check which PHP limit is actually allowed and used by the hosting system.
php.ini, .user.ini and other PHP configurations #
Depending on the PHP operation mode, settings can be made via, among other things:
php.ini
or:
.user.ini
to be configured.
Which method is supported depends on the server environment.
Therefore, you should not blindly create configuration files from a third-party guide. A directive that works on one server does not necessarily have the same effect in a different PHP configuration.
Do not confuse the memory limit with upload limits #
The PHP memory limit does not directly determine the maximum file size of an upload.
Among other things, there are dedicated PHP settings for this, such as:
upload_max_filesize
and
post_max_size
An upload can therefore fail due to a size limit, even though sufficient PHP memory would be available.
Do not confuse memory limit with max_execution_time #
The maximum execution time is also a separate PHP setting.
A process can have sufficient RAM and still terminate due to a time limit.
Conversely, a very fast process can exceed the memory limit.
Therefore, during troubleshooting, the specific error message should always be examined.
Memory Limit and Hosting Resources #
The PHP memory limit is just one of several resource limits.
In a hosting environment, additional limits for CPU, processes, I/O, or the total available memory of an account may also apply.
A high value in memory_limit does therefore not mean that an unlimited number of PHP processes can each use the maximum value at the same time.
Why an extremely high memory limit can be problematic #
A very high limit can cause a faulty PHP process to consume significantly more memory before it is terminated.
With several simultaneous processes, this can place a heavier load on the available resources of a hosting environment.
A sensible memory limit should therefore provide sufficient leeway, but not serve as a replacement for proper resource management.
Set memory limit to „unlimited“? #
PHP can generally have configurations where no normal memory limit is set. For a production WordPress website, however, simply providing unlimited memory to a faulty process is not a good general solution.
A limit also protects the environment from faulty code uncontrollably consuming more and more memory.
Memory issue or memory leak? #
If the memory consumption within a process continuously increases, there may be an error in the program logic or unfavorable processing of large amounts of data.
A higher limit might then simply postpone the termination.
If the same process repeatedly exhausts all available memory even with a greatly increased limit, root cause analysis is more important than another increase.
Compare memory usage after changes #
If a memory issue occurred after a specific change, a comparison is particularly helpful.
For example, if a new plugin has been activated and memory consumption has increased significantly since then, this extension should be investigated.
The same applies to new theme features, imports, additional WooCommerce extensions, or custom code.
A higher limit can still be the right solution #
Not every memory error means that WordPress or a plugin is working incorrectly.
If a legitimate process understandably requires more memory than the previous limit allows, a moderate increase can make complete technical sense.
This applies, for example, to certain image processing, import, or administration processes.
What is crucial is that the required memory is plausible and that the process is completed stably after the adjustment.
Retest after a change #
Once you have adjusted the memory limit, you should repeat the exact process that failed previously.
If it works afterwards, still check whether the memory consumption is plausible and no new errors appear in the log.
If the limit is reached again after a short time, the cause should be investigated in more detail.
What you had better not do in the event of a memory error #
Do not simply keep setting higher values in wp-config.php, without even checking whether they will become effective at all and why the storage is needed.
Also, do not delete plugins indiscriminately just because their filename appears in the last fatal error. The mentioned file does not necessarily have to be the main cause of the overall memory consumption.
Do not confuse the memory limit with the upload size, execution time, CPU, or the total RAM of the server.
And do not automatically treat unusually high memory consumption as a hosting issue before plugins, theme, code, and the specific process have been investigated.
Basic rule: A memory limit should be high enough for legitimate WordPress processes to function reliably. However, if the limit is reached unexpectedly, you should first determine which process requires the memory and why.
What information helps CURIAWEB support? #
If your WordPress website shows a memory error at CURIAWEB, please send the complete relevant error message or the respective excerpt from the error log if possible.
Particularly helpful are the time of the error and a description of the action during which it occurs. For example, if the problem only occurs when editing a specific page, during an import, during a backup, or in the WooCommerce checkout, that should be mentioned.
Also report whether a plugin, theme, WordPress, or the PHP version was updated or changed immediately beforehand.
With this information, it is much easier to assess whether more memory is actually needed or whether a specific component is causing an unusually high memory consumption.
Do not send passwords unsolicited.
Summary #
The PHP memory limit restricts the amount of memory that PHP can use during execution. If this limit is exceeded, PHP can stop processing with an error such as Allowed memory size ... exhausted Cancel.
In WordPress, a distinction must be made between several levels. The server-side PHPmemory_limit is not the same as the WordPress constants WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT. A in wp-config.php Furthermore, a registered high value cannot automatically override a server-side maximum.
A higher memory limit does not automatically make WordPress faster. It makes sense if a legitimate process requires more memory than previously allowed. If consumption increases uncontrollably due to a faulty plugin, a problematic loop, or another technical cause, however, a higher limit may simply postpone the next error.
The correct procedure is therefore: check the error message, determine the actual memory limits, identify the affected process, and only then decide whether the limit needs to be adjusted or the actual root cause fixed.