How to Increase the WordPress Memory Limit
Every WordPress site runs on PHP and PHP needs memory to do its work. When WordPress doesn’t have enough memory to complete a task, things break. You might see a blank white screen, a “Fatal error: Allowed memory size exhausted” message or the more recent “There has been a critical error on this website” notice. Increasing the WordPress memory limit is one of the most common fixes site owners need to perform, yet it’s often misunderstood. If you’re running into memory problems and want expert help, WordPress support and troubleshooting services from Priority Pixels can diagnose the root cause and get your site running smoothly again.
WordPress memory limit determines how much server RAM any single PHP process gets to use. Front-end pages get 40MB by default, while admin operations like installing plugins or uploading media get 256MB. But your hosting provider probably overrides these numbers with their own limits. Could be higher, could be lower, depends on what you’re paying for. Exceed that limit and PHP kills the process stone dead, throwing a fatal error. It’s a safety feature that stops one rogue script from hogging all the server resources and crashing every site sharing that server.
Signs That You’ve Hit the Memory Limit
Memory problems don’t always shout at you with clear error messages. Sure, you might see “Allowed memory size of X bytes exhausted” if your site’s set to show PHP errors, but most production sites hide those messages for security reasons.
Watch for intermittent white screens instead. Some pages load perfectly while others just go blank, which usually means the failing pages need more memory to render properly. Pages packed with dynamic content or heavy plugins are the main culprits. And if your site runs fine during quiet periods but starts breaking under heavy traffic, you’re probably hitting total server memory limits rather than the per-process cap. The WordPress admin struggles too, especially when you’re working with large pages in the block editor or running bulk operations.
Checking your current memory limit doesn’t require messing with config files. Build a simple PHP file or just use WordPress Site Health under Tools > Site Health in your dashboard. The Info tab displays your PHP memory limit alongside other server configuration details. The WordPress debugging documentation walks you through enabling error logging if you need deeper insight into what’s eating up your memory.
The WordPress memory limit is a per-process cap, not a total server limit. Increasing it lets each individual page request use more RAM, but it won’t help if your server’s total memory is already fully allocated across multiple concurrent requests.
Your hosting plan comes with a fixed amount of total RAM, which means raising the per-process PHP memory limit can backfire. Each request gets more resources but you’ll hit the wall faster when multiple users visit your site at once.
Increasing the Memory Limit via wp-config.php
Adding a constant to your wp-config.php file works every time. You’ll find this file in your WordPress root directory where it controls database credentials, security keys and debugging options, so you’ll need FTP, SFTP or your hosting provider’s file manager to reach it.
Find the line that reads /* That's all, stop editing! Happy publishing. */ when you open wp-config.php. Add the following line above it:
define( 'WP_MEMORY_LIMIT', '256M' );
WordPress will now request 256 megabytes of memory from the server for front-end operations. But admin-side tasks often need more juice, so you can set a separate higher limit for those:
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
WordPress admin pages and background processes like updates and cron jobs need more memory than your typical front-end page, which is why WP_MAX_MEMORY_LIMIT exists. Admin tasks are naturally memory-intensive so bumping this constant higher than your front-end limit just makes practical sense. Upload your modified file back to the server and refresh your site to check if that error has disappeared.
Your hosting provider needs to allow the memory allocation you’ve set in wp-config.php, otherwise you’re wasting your time. WordPress can only request memory up to whatever the server’s maximum allows, so if your host caps PHP memory at 128MB server-side, that WP_MEMORY_LIMIT of 256MB becomes completely pointless.
Alternative Methods for Changing the Limit
Several other methods exist when wp-config.php won’t cooperate or when you need to change the server-level PHP memory limit instead of just the WordPress-specific setting. Apache servers can use the .htaccess file to set PHP memory limits. Drop this line into your .htaccess file in the WordPress root directory:
php_value memory_limit 256M
Apache servers with mod_php will accept this directive, but it sets the memory limit for every PHP process in that directory. Your WordPress site won’t be the only thing affected. Hosts running PHP-FPM or Nginx will either ignore this completely or throw a 500 error that breaks your site. The PHP documentation on memory_limit covers the technical details of how this directive works at the server level.
Edit php.ini directly when you’ve got server access to PHP configuration files. Create or find a php.ini file in your WordPress root directory and add this line (some hosts accept .user.ini instead):
memory_limit = 256M
Changing PHP’s configuration at source level gives you the most control. Most shared hosting providers block access to the main php.ini file, but they’ll often let you override settings with .user.ini files in individual directories. And if file-based methods don’t work, check your hosting provider’s control panel for a PHP configuration section where you can adjust memory limits through their interface. Start with wp-config.php because it’s the safest option and only affects WordPress.
When Memory Issues Point to Deeper Problems
Something’s wrong if you keep pushing that memory limit higher and higher. Sure, bumping it up from the standard 256MB works when your site needs more resources, but constantly raising it means there’s a deeper problem lurking in your codebase. You’re just masking performance issues that’ll snowball into bigger headaches down the road.
Badly written plugins eat memory like there’s no tomorrow. They’ll load everything on every single page whether it’s needed or not, run messy database queries without caching or dump massive data sets into memory instead of processing them bit by bit. Notice your memory usage shoot up after installing something new? Start there. The WordPress plugin developer guidelines exist for good reason, but plenty of developers ignore them completely.
Query Monitor shows you exactly what’s hogging your memory on each page. Install this WordPress plugin and you’ll see which components are the worst offenders. And if one plugin is burning through more memory than your entire theme and every other plugin combined, ditch it for something better built. That beats cranking up the memory limit every few months. Good WordPress development means being ruthless about plugin choices.
Optimising Your Site to Reduce Memory Usage
Cut your WordPress site’s memory usage with some smart optimisations that work across everything. Your performance improves and you won’t hit those memory walls even when your content and traffic grow.
Every active plugin on your site needs questioning. WordPress sites collect plugins like dust over time as you add features and forget to clean up afterwards. We’ve seen sites running twenty plugins when five would do the job better. Deactivating unused plugins frees up memory instantly. But here’s what works even better: find plugins that handle multiple tasks instead of running separate tools for everything.
- Remove unused plugins entirely rather than just deactivating them
- Replace heavy multipurpose plugins with lightweight alternatives where you only need one feature
- Enable object caching (Redis or Memcached) to reduce repeated database queries
- Use a caching plugin to serve static HTML instead of processing PHP on every request
- Optimise images before uploading to reduce processing overhead
- Limit post revisions to prevent database bloat that affects query performance
Object caching changes everything about how WordPress handles database queries. Without it, every page view means WordPress hits the database repeatedly to grab content, widgets, menus and plugin settings from scratch. Redis or Memcached store those query results in memory so the next visitor gets served cached data instead of triggering fresh database calls. Your WordPress managed hosting provider might include object caching already, so check that before adding another plugin to the mix.
Databases get messy fast. Post revisions pile up, transient data hangs around and spam comments create overhead that slows everything down. WP-Optimize handles the cleanup automatically, though you can run SQL queries directly if you prefer getting your hands dirty.
Choosing the Right Hosting for Your Memory Needs
Shared hosting puts a hard limit on what you can achieve because you’re sharing server resources with dozens of other sites. The hosting company sets strict memory limits per process to stop one site from crashing everyone else’s. Hitting those limits consistently means it’s time to move to a VPS or managed WordPress hosting where you get dedicated resources and actual control over PHP settings.
Business-critical sites get what they pay for with managed WordPress hosting. You’re looking at higher default memory limits, built-in object caching and automatic PHP version management that takes the pressure off your site. But there’s a cost trade-off here and some flexibility restrictions too. Managed hosts charge more than basic shared plans and they’ll often limit which plugins you can install or restrict your server access. Still, the reliability and performance benefits usually justify the extra spend. Pair solid hosting with professional technical SEO and your site performs well for users and search engines alike.
Don’t just look at the headline memory figure when you’re choosing hosting. A host offering 512MB of PHP memory on a server with slow disk I/O and limited CPU cores will likely perform worse than 256MB on faster hardware and that’s what matters. Ask about their PHP handler because PHP-FPM beats mod_php for speed. Check if OPcache is enabled since it caches compiled PHP code and reduces processing overhead. The WordPress server requirements page gives you minimums and recommendations, but production sites handling real traffic need to exceed those minimums by a comfortable margin.
WordPress memory issues aren’t mysterious once you know where to look. The fix is often just one line in a configuration file, but that’s not really the point. Are you addressing the real problem or just covering up something that needs proper attention? Sites that run comfortably within standard memory limits are well built, well maintained and hosted appropriately. Constantly fighting memory errors means it’s time to audit your plugins, review your hosting setup and check whether your site’s foundations can support the growth you’re planning.
FAQs
What is the WordPress memory limit and why does it matter?
The WordPress memory limit is a cap on how much server RAM each individual PHP process can use. WordPress defaults to 40MB for front-end pages and 256MB for admin tasks like plugin installations and media uploads. When a process hits this limit, PHP terminates it with a fatal error, resulting in white screens, critical error messages or the “Allowed memory size exhausted” warning. This safety mechanism prevents a single rogue script from consuming all available server resources, but it can cause problems on sites with resource-intensive plugins or complex page layouts.
How do I increase the WordPress memory limit in wp-config.php?
Open your wp-config.php file via FTP or your hosting file manager and add the line define WP_MEMORY_LIMIT 256M above the comment that reads “That’s all, stop editing”. For admin tasks, you can set a separate higher limit with define WP_MAX_MEMORY_LIMIT 512M. Save the file and refresh your site to check whether the error has resolved. Be aware that your hosting provider may enforce their own server-level memory cap that overrides whatever you set in wp-config.php. If the change has no effect, you may need to adjust the limit through php.ini, .htaccess or your hosting control panel instead.
Should I just keep increasing the WordPress memory limit to fix errors?
Increasing the memory limit is a quick fix, but it does not address the underlying cause of excessive memory consumption. A plugin with a memory leak or an inefficient database query will continue eating more resources as your site grows. Investigate which plugins and processes are consuming the most memory by using debugging tools and server monitoring. Also remember that the memory limit is a per-process cap, so raising it means each visitor request can grab more RAM, which may actually reduce the number of concurrent visitors your server can handle before running out of total available memory.