banner-img

How to Increase WordPress Memory Limit: An Ultimate Technical Guide

If your WordPress site starts crashing while uploading files, running scripts, or activating plugins, there is a chance that your PHP memory limit is not sufficient. This common issue can break features, slow things down, or trigger the dreaded “Allowed memory size exhausted” error.

Thankfully, increasing the memory limit in WordPress is easier than it sounds. From simple config edits to server-side changes, you’ve got multiple options—no need to panic or rely on guesswork.

Whether you’re handling it yourself or working with a WordPress development agency, knowing how memory allocation works is the first step. Let’s start by understanding what the WordPress memory limit is and why it matters.

What is the PHP Memory Limit in WordPress?

Every time WordPress loads a page, runs a plugin, or processes a task, it uses PHP (the scripting language it’s built on). Like any application, PHP needs memory to function.

The PHP memory limit defines how much memory a single PHP script is allowed to use on your server. If WordPress needs more than what’s available, it crashes or throws errors. This limit is set in your hosting environment, but WordPress also sets its own limits through two key constants:

WP_MEMORY_LIMIT

This constant defines the maximum memory WordPress can use for frontend/public-facing pages.

Example:

define('WP_MEMORY_LIMIT', '128M');

This would allow WordPress to use up to 128MB of memory for regular user-facing operations.

WP_MAX_MEMORY_LIMIT

This one controls the memory limit for admin-side tasks – like editing large posts, importing data, running backups, or working inside a page builder.

Example:

define('WP_MAX_MEMORY_LIMIT', '256M');

With this, backend processes can use up to 256MB, even if the frontend limit is lower.

Tip: Many users set only WP_MEMORY_LIMIT and still experience issues in the admin area. It’s a good practice to define both constants to ensure consistency across your site.

Getting familiar with these limits is the first step to resolving memory-related issues. Next, we’ll explore how to check your current limit and walk through the safest ways to increase it.

How to Check Your Current WordPress Memory Limit?

Before you increase the memory limit, it’s important to know what you’re currently working with. WordPress and your server offer a few simple ways to check the existing memory allocation. Here are some reliable methods suited for both beginners and advanced users.

WordPress Site Health Tool (Beginner-Friendly)

WordPress has a built-in tool that shows useful server information:

  • Go to your WordPress admin dashboard.
  • Navigate to Tools → Site Health → Info.
  • Expand the Server section.
  • Look for PHP memory limits.

This is the easiest and safest method, requiring no code or plugins.

Using a phpinfo.php File (Direct Server Info)

Create a new PHP file in your root directory (where wp-config.php is), and name it something like phpinfo.php.

Code:

<?php phpinfo(); ?>

Upload it via FTP or File Manager and open it in your browser:
Example: https://yoursite.com/phpinfo.php

Look for the line:

memory_limit => 128M => 128M

The value shown is your current memory limit. Don’t forget to delete this file afterward for security reasons.

Using a Plugin (One-Click Method)

Install a plugin like Query Monitor or WP-ServerInfo to quickly view PHP memory and other server settings within the WordPress dashboard. Here’s a quick look from “Query Monitor – The developer tools panel for WordPress”.

Here’s a quick look from “WP-ServerInfo”.

This is great for users who prefer not to access server files directly.

Using SSH/Command Line (Advanced)

If you have SSH access, run this command to check memory directly from the server:

php -i | grep memory

It will return something like:

memory_limit => 128M => 128M

It’s perfect for developers working on VPS or dedicated servers. Each method offers a different level of insight, depending on your setup. Once you know your current memory limit, you’re ready to move on to increasing it–safely and effectively.

Methods to Increase Memory Limit in WordPress

Once you’ve confirmed your current PHP memory limit, it’s time to increase it, especially if you’re running into performance issues, plugin errors, or white screens. Below are five tried-and-tested methods, each tailored to different types of hosting setups. Choose the one that fits your environment and comfort level.

Note: Not all hosts allow all methods. If one doesn’t work, try another or contact your hosting support.

Method 1: Edit wp-config.php (Most WordPress-Friendly)

This method is safe and works on most installations where you have file access.

Steps:

  1. Go to your site’s root directory (where wp-config.php is located).
  2. Open wp-config.php in a text editor.
  3. Add these lines just before the line that says /* That’s all, stop editing! */:
define('WP_MEMORY_LIMIT', '256M');

define('WP_MAX_MEMORY_LIMIT', '256M');

This increases the memory for both frontend and backend processes.

Method 2: Modify php.ini (Server-Level, Best for VPS/Dedicated)

If you manage your own server or have access to PHP configuration:

Steps:

  1. Locate or create a php.ini file in your site’s root folder.
  2. Add or update the following line:
memory_limit = 256M

This globally sets PHP memory limits. It may not work on shared hosting unless explicitly allowed.

Method 3: Edit .htaccess (Apache Servers Only)

If your site runs on Apache (most shared hosting does), you can increase memory via .htaccess.

Steps:

  1. Open the .htaccess file in your root directory.
  2. Add this line:
php_value memory_limit 256M

Warning: This might trigger a 500 Internal Server Error if your server doesn’t allow PHP settings in .htaccess.

Method 4: Use Hosting Control Panel (cPanel, Plesk, etc.)

If your host offers a control panel, you can often change PHP settings there:

In cPanel:

  • Go to Select PHP Version → Options or MultiPHP INI Editor.
  • Find memory_limit and set it to 256M or higher.

This is the easiest way for shared hosting users if file edits aren’t allowed.

Method 5: Create/Edit user.ini (For PHP-FPM & Shared Hosting)

If you’re using PHP-FPM (common in modern shared hosting), .htaccess or php.ini changes might not apply. In that case, use a .user.ini file.

Steps:

  1. In your site’s root directory, create or edit .user.ini.
  2. Add this line:
memory_limit = 256M

The changes may take a few minutes to apply. These methods cover nearly every hosting setup, from shared hosting to advanced VPS environments. Test your site after making changes, and verify the new limit using the methods we covered earlier. If one approach doesn’t work, don’t worry–try the next one on the list.

Advanced Tips for WordPress Memory Management

Most tutorials stop at showing you how to increase the memory limit, but there are a few deeper considerations that can really help optimize your WordPress setup. These tips address what’s often overlooked but make a real difference–especially for developers, site managers, or anyone running resource-heavy websites.

Increasing Memory Limit Doesn’t Increase Server Resources

Boosting the memory limit in WordPress only tells PHP it’s allowed to use more memory. It doesn’t magically increase the actual available memory on your server.

Example:
If your server only has 512MB of total memory and you allow WordPress to use 512M, other processes (like MySQL or Nginx) might get starved and crash.

Insight: Always balance the memory limit with your actual server specs. On shared hosting, 128M–256M is safe. On a VPS, you can afford more–but monitor resource usage.

Different Limits Apply in Different Contexts

WordPress memory limits can vary depending on the environment:

  • Cron jobs, AJAX calls, and background tasks may not respect WP_MEMORY_LIMIT.
  • Command-line tools like WP-CLI have their own limits based on system-wide PHP settings.

Set limits at both the WordPress level (wp-config.php) and PHP level (php.ini or .user.ini) for full coverage.

Debugging Memory Usage with memory_get_usage()

If you’re developing or debugging, use the memory_get_usage() and memory_get_peak_usage() functions to see how much memory is being consumed.

Example:

echo 'Memory used: ' . round(memory_get_usage() / 1048576, 2) . ' MB';

echo 'Peak memory: ' . round(memory_get_peak_usage() / 1048576, 2) . ' MB';

This helps you identify plugins or functions that consume too much memory, especially on complex or bloated sites.

Limit Doesn’t Apply to All Errors

Even if you raise the memory limit, fatal errors like out-of-memory exceptions may still occur if a process tries to exceed it in one go–especially during:

  • Importing large files.
  • Running backups or migrations.
  • Using heavy page builders.

Break large tasks into smaller chunks or use tools with memory-efficient design (like WP All Import with chunked imports).

Knowing about the best practices will help you adopt a smarter approach for WordPress memory management. Setting up the memory limit will you avoid crashes along with speeding up the WordPress dashboard.

FAQs to Increase Memory Limit in WordPress Sites

How much memory does a WordPress site need?

For most WordPress sites, 128MB of memory is enough. But if you’re running heavy themes, large plugins, or WooCommerce, aim for 256MB or more to avoid memory-related issues and improve performance.

How do I check my WordPress memory limit?

You can check your WordPress memory limit by using:

– Site Health Tool (under Tools > Site Health > Info tab)
– A phpinfo.php file uploaded to your server
– Memory display plugins like WP Server Info
– Or CLI: wp –info via WP-CLI

Does WordPress have a storage limit?

WordPress itself doesn’t have a storage limit, but your web hosting plan does. Storage depends on your hosting provider—shared hosting may offer 1–10GB, while managed or VPS hosting gives more flexibility.

What is the maximum memory size for WordPress?

There’s no strict limit for memory size from WordPress, but 512MB is generally the upper recommended threshold. The actual max depends on your server config and PHP settings (like memory_limit in php.ini).

What is the allowed memory size of exhausted in WordPress?

It’s an error that means WordPress used all the allocated PHP memory and couldn’t complete the process. To fix it, you need to increase the memory limit in wp-config.php or through server settings.

Let’s Summarize

Running into memory limit issues is frustrating, but the fix is usually straightforward. Whether it’s tweaking your wp-config.php, editing server files, or using hosting tools, there’s always a method that fits your setup.

Understanding how memory allocation works can help prevent crashes, improve performance, and ensure your site scales smoothly as it grows. It’s one of those behind-the-scenes fixes that make a big difference.

If you’re looking for a stable, high-performance WordPress setup, our WordPress experts can help. Contact us today, and let’s optimize your site together.

Bijal Shah
Bijal Shah

Bijal Shah is a skilled WordPress expert and technical content writer with a passion for making complex topics easy to understand. With her expertise in web development and CMS platforms, Bijal specializes in creating clear, informative, and practical content that helps businesses navigate the digital world.

Leave a Comment

30 days Money Back Guarantee
Secure Online Payment
1 Year of Updates & Support