The error behind the white screen
You are updating a WooCommerce product catalogue. Or importing a large CSV file. Or just visiting your homepage on a busy day. And instead of your site, you see one of these:
"Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 20480 bytes) in /home/user/public_html/wp-includes/class-wpdb.php on line 2056"
Or, worse, you see nothing at all. Just a blank white screen. Or a generic 500 Internal Server Error page from your hosting provider. No explanation, no clue, no debug information.
Behind all three of these symptoms is the same problem: PHP ran out of memory.
That number in the error message — 41943040 bytes — is 40MB. That is the default PHP memory limit on many shared hosting providers. Your WordPress site, with all its plugins and themes and database queries, tried to use more than 40MB of memory on a single page load, and PHP killed the process.
The result? Your site is down. Not just the page you were looking at — potentially every page, depending on which plugin or process exhausted the memory. If it happens on a core WordPress file like class-wpdb.php, it can take down every page that touches the database. Which is every page.
Your visitors see a white screen or a 500 error. Your WooCommerce orders stop processing. Your forms stop submitting. And because the error can be intermittent — appearing only under load — you might not see it when you check your site yourself.
Why PHP has a memory limit at all
PHP sets a memory limit to prevent a single script from consuming all available server RAM. Without it, one misbehaving plugin could crash the entire server, taking down every site hosted on it.
The limit is configured at the server level and applies per-request. Every time a visitor loads a page, PHP starts a new process, and that process gets a fixed amount of memory to work with. If the page requires more memory than the limit allows, PHP kills the process.
The PHP documentation for memory_limit explains how the limit works at a technical level. For WordPress specifically, the issue is that 40MB or 64MB — the defaults on most shared hosting — is simply not enough for a modern WordPress site with multiple plugins.
What causes the memory to run out
Knowing why PHP has a limit is useful. But you need to know why your site is exceeding it. Here are the most common causes, from most frequent to least.
1. Too many plugins loaded simultaneously
Every active plugin consumes memory on every page load, even if it only does something on specific pages. A plugin that adds a contact form to one page still loads its PHP classes and hooks on every page. Twenty active plugins loading on every request can easily push a site past 40MB.
The typical WordPress site with a page builder, a forms plugin, an SEO plugin, a security plugin, a caching plugin, an analytics plugin, and a few others is running right at the edge of 64MB. Add a WooCommerce store on top of that and you are past 128MB before any actual content is processed.
2. Plugin memory leaks
Some plugins have inefficient code that consumes far more memory than necessary. A common pattern is loading an entire dataset into memory instead of processing it in chunks. A plugin that imports 10,000 products by loading all of them into a PHP array at once can consume hundreds of megabytes.
Memory leaks are hard to detect because they might not show up during normal browsing. They appear during specific operations — imports, exports, report generation, sitemap building — that are often run by cron jobs or admin users, not regular visitors.
3. Large WooCommerce operations
WooCommerce is a significant memory consumer on its own. Adding products with many variations, running sales reports over large date ranges, importing product catalogues via CSV, or generating PDF invoices for large orders can all push past the memory limit.
The problem is amplified on shared hosting where the memory limit is low and cannot be easily increased. A WooCommerce store with 5,000 products needs substantially more memory than a simple blog.
4. Large media uploads and image processing
When you upload an image, WordPress generates multiple sizes — thumbnail, medium, large, and any custom sizes your theme defines. Processing a 5MB image into six different sizes requires significant memory. If your theme defines four custom sizes and you upload a high-resolution image, PHP can run out of memory during the resize operations.
This is especially common when uploading multiple images at once via the media library bulk uploader.
5. The default memory limit is simply too low
Many shared hosting providers set the PHP memory limit to 40MB or 64MB. WordPress itself recommends a minimum of 64MB, and WooCommerce recommends 128MB. If your host is set at 40MB, even a basic WordPress installation with a handful of popular plugins will hit the limit under any kind of load.
Four ways to increase the PHP memory limit
The immediate fix is to increase the memory limit. There are four methods, and which one works depends on your hosting setup. Try them in this order.
Method 1: wp-config.php (works on most hosts)
This is the most common and most reliable method. Open wp-config.phpvia FTP or your hosting file manager. Add this line before the "That's all, stop editing" comment:
define('WP_MEMORY_LIMIT', '256M');
For admin operations that need more memory (like plugin updates or WooCommerce imports), you can also set a separate admin limit:
define('WP_MAX_MEMORY_LIMIT', '512M');
Save the file and reload your site. If the error disappears, you are done — for now. Note that some hosting providers override this setting at the server level, in which case you need one of the other methods.
Method 2: php.ini (if your host allows it)
The php.ini file controls PHP settings at the server level. If your host allows you to create or edit a php.ini file in your WordPress root directory, add this line:
memory_limit = 256M
Some hosts use .user.ini instead of php.ini. If you are unsure, check your hosting documentation or create a simple PHP info file to see which configuration files PHP is reading. The PHP core ini directives documentation lists all available settings.
Method 3: .htaccess (Apache servers only)
If your WordPress site runs on Apache (which most shared hosting uses), you can set the PHP memory limit in your .htaccess file. Add this line:
php_value memory_limit 256M
Place this line above the WordPress rewrite rules. Note that this only works if your host allows PHP value overrides via .htaccess. Some security-hardened hosts disable this.
Method 4: Hosting control panel
Many hosting providers offer a PHP settings page in their control panel (cPanel, Plesk, or a custom dashboard). Look for a "PHP Configuration," "PHP Settings," or "MultiPHP INI Editor" section. Change the memory_limit value to 256M or higher.
This is the most reliable method because it sets the limit at the server level, where no WordPress setting or plugin can override it. If your hosting provider does not offer this option and the other methods do not work, contact their support and ask them to increase the limit for your account.
Finding the real culprit
Increasing the memory limit stops the immediate crash. But if a plugin is consuming 200MB per request, raising the limit to 256MB just buys you time until traffic increases or another plugin pushes you over the new limit. You need to find what is consuming the memory and fix it.
Check the error message itself
The fatal error message tells you exactly which file exhausted the memory. If it says /wp-content/plugins/some-plugin/includes/class-import.php, you know which plugin is responsible. If it points to a WordPress core file like class-wpdb.php, the root cause is usually a plugin making an enormous database query.
Enable WordPress debug logging
Add these lines to wp-config.php:
define('WP_DEBUG', true);define('WP_DEBUG_LOG', true);define('WP_DEBUG_DISPLAY', false);
This logs all PHP errors and warnings to /wp-content/debug.log without showing them to visitors. Check this file after the memory error occurs — it often shows a trail of warnings leading up to the crash that points to the guilty plugin.
Deactivate plugins one by one
The definitive way to find the culprit. Deactivate all plugins, then reactivate them one at a time, loading a page between each activation. When the memory error returns, the last plugin you activated is the problem. This is tedious but reliable.
Review what you changed recently
If the error started suddenly, think about what changed. Did you update a plugin? Install a new one? Import a large dataset? Change your theme? The most recent change is almost always the cause.
How Uptrue catches the crash automatically
The PHP memory exhausted error manifests as a 500 error or a white screen to your visitors. Both are detectable with the right monitoring setup. Uptrue catches both within 60 seconds.
Step 1: Set up an HTTP monitor
- Sign up at uptrue.io/signup (free plan available)
- Click Add Monitor from your dashboard
- Select HTTP/HTTPS as the monitor type
- Enter your WordPress site URL
- Set the expected status code to 200
- Set the check interval to 1 minute
- Configure alerts — Slack, email, or Microsoft Teams
When PHP runs out of memory and the server returns a 500 error, the HTTP monitor catches it immediately and alerts you. This is the most common manifestation of the memory error.
Step 2: Set up a keyword monitor for the white screen
- Click Add Monitor again
- Select Keyword as the monitor type
- Enter your homepage URL
- Set the keyword to your site title or a phrase always present on your homepage
- Set the check type to "Page must contain"
- Set interval to 1 minute
Sometimes the memory error does not return a 500 status — it returns a 200 with a blank body (the White Screen of Death). The keyword monitor catches this by checking that your expected content is actually there. If the page is blank, the keyword is missing, and you get alerted.
Step 3: Monitor your high-memory pages
The memory error often affects specific pages more than others — pages that load more plugins, process more data, or display more content. Set up additional monitors for:
- Your WooCommerce shop page (loads product data)
- Your checkout page (loads payment gateways)
- Your most content-heavy blog post
- Any page with a complex form or interactive element
- Your wp-admin dashboard (often the first to crash)
Step 4: Set up alerts that wake you up
Memory errors can be intermittent — they happen under load and disappear when traffic drops. If you only check email once an hour, you might miss a memory crash that lasted 20 minutes during your busiest traffic period. Configure alerts for immediate delivery:
- Slack — real-time notification in a dedicated channel
- Microsoft Teams — same concept, different platform
- Webhook — route to PagerDuty, Opsgenie, or your own alerting system
- Email — as a backup for less urgent awareness
Check your WordPress site health right now
Instant health score across uptime, SSL, DNS, security headers, and performance. See if your site is vulnerable to memory-related outages.
Check Your Website ScorePreventing memory exhaustion long term
Raising the memory limit and setting up monitoring are the immediate steps. But to prevent the error from recurring, you need to address the underlying causes.
Audit your plugins ruthlessly
Deactivate and delete every plugin you are not actively using. Every active plugin consumes memory on every page load, even if it has nothing to do with the page being viewed. If you have 30 active plugins and only use 15 regularly, you are wasting memory on every request.
Choose lightweight plugin alternatives
Not all plugins are created equal. A contact form plugin that loads a 5MB JavaScript framework on every page is not the same as one that loads a 20KB script only on the contact page. Research memory usage and performance impact before choosing plugins. Free website analysis tools can help you measure the impact.
Optimise your images before uploading
Compress and resize images before uploading them to WordPress. A 10MB image from your camera does not need to be uploaded at full resolution. Resize to the maximum display size your theme uses (usually 1200px to 2000px wide) and compress it. This reduces the memory needed for WordPress to process and resize the image.
Process imports in smaller batches
If you are importing products, posts, or users via CSV, split the file into smaller batches. Instead of importing 10,000 products at once, import 500 at a time. This keeps memory usage per-request well within limits.
Upgrade your hosting if you are on shared
Shared hosting with a 40MB memory limit is not designed for a WordPress site with WooCommerce, a page builder, and a dozen plugins. If you are hitting memory limits regularly, it is time to move to managed WordPress hosting or a VPS where you control the memory allocation. The cost difference is usually small compared to the revenue you lose during outages.
Stop finding out from your customers
Your WordPress site could be throwing memory errors right now — intermittently, under load, during your busiest traffic hours — and you would not know.
The PHP memory exhausted error is one of the most common WordPress crashes and one of the hardest to catch without monitoring. It can manifest as a 500 error, a white screen, or the "critical error" message. It can be intermittent, only appearing under specific conditions or traffic levels.
Uptrue monitors your site every 60 seconds with both HTTP and keyword monitoring. Whether the memory crash causes a 500 error or a blank white page, you know about it in under a minute. Fix it before your customers notice. Fix it before Google crawls the broken page. Fix it before you lose another sale.
Catch memory crashes before your visitors do
Free plan available. HTTP and keyword monitoring. AI-powered reports. No credit card required.
Frequently asked questions
What does "Allowed memory size exhausted" mean in WordPress?
This error means a PHP script on your WordPress site tried to use more memory than the server allows. PHP has a memory limit (typically 40MB to 128MB) set by your hosting provider. When a WordPress plugin, theme, or core process exceeds that limit, PHP kills the script and throws a fatal error. The result is usually a white screen, a 500 Internal Server Error, or the WordPress critical error message.
What is the recommended PHP memory limit for WordPress?
WordPress recommends a minimum of 64MB for basic sites and 128MB to 256MB for sites running WooCommerce, page builders, or multiple plugins. For large WooCommerce stores with many products or sites running complex import/export operations, 512MB may be necessary. Setting the limit too high is not harmful — it just defines the maximum a script can use, not what it will use on every request.
Will increasing the memory limit fix the problem permanently?
Increasing the memory limit fixes the immediate error, but it does not address the root cause. If a plugin has a memory leak or inefficient code, it will eventually hit even a higher limit — especially under traffic spikes or during large operations. You should increase the limit to stop the immediate crash, then investigate which plugin or process is consuming excessive memory and address it directly.
Can uptime monitoring detect a PHP memory exhausted error?
Yes. When PHP runs out of memory, the result is typically a 500 Internal Server Error or a blank white page. An HTTP monitor catches the 500 error directly. A keyword monitor catches the white page by detecting that your expected content is missing. Together, they provide complete coverage — you know about the crash within 60 seconds, regardless of how the error manifests.