Roconpaas

Blog

Increase Memory Limit in WordPress – Fix in Minutes!

March 11, 2025 by Benjamin

WordPress Keeps Logging Me Out

Introduction

Increase Memory Limit in WordPress: WordPress is a powerful content management system (CMS) that hosts millions of websites around the world. However, as your website grows in complexity, you may encounter low memory limit errors. These errors can disrupt your website’s functionality, slow down performance, and even complete failures in executing important scripts.

The majority of WordPress users experience memory limit problems, especially when hosting resource-intensive plugins, complex themes, or active websites. When the memory is not properly assigned, operations such as media uploads, database queries, and page loads can fail. In this tutorial, we will guide you through the process needed to increase your WordPress memory limit and prevent frustrating errors.

By the end of this tutorial, you will:

  • Understand how WordPress memory works
  • Identify common memory limit errors
  • Learn various methods to increase the memory limit
  • Optimize WordPress for better utilization of memory
  • Debug common errors while increasing memory

Let us enter the world of WordPress memory limits and learn practical solutions to keep your site live.

 

buy 1 get 1 offer

Are You Struggling with Slow WordPress Hosting?

Switch to Rocon for high performance and reliabile WordPress hosting for your website!

Understanding WordPress Memory Limit

What is the WordPress Memory Limit?

Every WordPress installation operates within a memory limit set by the hosting environment. This limit dictates how much memory PHP scripts can use when running your website. By default, WordPress attempts to allocate 40MB for a single-site installation and 64MB for multisite setups. However, this is often insufficient for websites with advanced functionalities.

The memory limit is controlled by the server’s PHP configuration and can be increased based on the hosting plan. If your website requires additional resources, you may need to manually adjust the memory allocation or request an upgrade from your hosting provider.

Why Does WordPress Need More Memory?

As your website expands with plugins, themes, and custom code, memory usage increases. Running out of memory can cause scripts to terminate unexpectedly, leading to incomplete processes or broken functionality. Some scenarios that require additional memory include:

  • Running WooCommerce or other resource-heavy plugins
  • Using page builders such as Elementor or WPBakery
  • Handling high volumes of traffic
  • Storing large media files, including high-resolution images and videos
  • Performing automated backups, imports, or migrations
  • Executing complex database queries

Increasing the memory limit ensures that your website runs efficiently, preventing crashes and slowdowns caused by insufficient memory allocation.

Identifying Memory-Related Errors in WordPress

If your WordPress site is running out of memory, you may encounter errors like:

  • Fatal error: Allowed memory size exhausted (e.g., Fatal error: Allowed memory size of 67108864 bytes exhausted)
  • White Screen of Death (WSOD): The website loads a blank white page with no error messages
  • Slow website performance: Pages take too long to load or fail to load altogether
  • Plugin or theme crashes: Some features may not work due to memory limitations

These errors indicate that your server is unable to allocate sufficient memory to execute PHP scripts. Increasing the memory limit can resolve these issues and improve overall performance.

Checking Your Current Memory Limit

Using the WordPress Site Health Tool

WordPress provides a built-in Site Health tool that displays memory limit information. To check your current memory limit:

  1. Navigate to Tools > Site Health in your WordPress dashboard.
  2. Click on the Info tab.
  3. Scroll down to the Server section.
  4. Look for PHP memory limit to see the allocated memory.

If your memory limit is below 256MB, you may need to increase it to accommodate advanced functionalities.

Checking Memory Limit via phpinfo()

You can retrieve PHP configuration details, including memory limit, by creating a phpinfo.php file:

  1. Open a text editor and create a new file named phpinfo.php.

Add the following code:
<?php

phpinfo();

?>

  1. Save the file and upload it to your WordPress root directory.
  2. Access the file via your browser (e.g., https://yourdomain.com/phpinfo.php).
  3. Search for “memory_limit” to find the current memory allocation.

Using a WordPress Plugin

Several plugins, such as WP-ServerInfo and Query Monitor, provide a detailed overview of your server settings, including memory limits. These tools make it easy to monitor resource usage without accessing configuration files manually.

Methods to Increase WordPress Memory Limit

1. Editing the wp-config.php File

One of the simplest ways to increase WordPress memory is by modifying the wp-config.php file.

Steps to Increase Memory via wp-config.php

  1. Locate the wp-config.php file in your WordPress root directory.
  2. Open the file using a text editor.
  3. Add the following line before the “That’s all, stop editing!” comment:
    define(‘WP_MEMORY_LIMIT’, ‘512M’);
  4. Save the file and upload it back to your server.
  5. Refresh your website and check if the memory limit has increased.

2. Modifying the .htaccess File

Another method involves modifying the .htaccess file, which controls server configurations.

Steps to Increase Memory via .htaccess

  1. Open the .htaccess file in your WordPress root directory.
  2. Add the following line at the end of the file:
    php_value memory_limit 512M
  3. Save the file and upload it.
  4. Check if the changes reflect on your website.

3. Adjusting the php.ini File

The php.ini file contains PHP settings, including memory limits. Modifying this file can effectively increase the available memory.

Steps to Increase Memory via php.ini

  1. Locate the php.ini file in your server’s root directory.
  2. Open the file using a text editor.
  3. Find the line containing memory_limit and modify it as follows:
    memory_limit = 512M
  4. Save the file and restart your server (if required).
  5. Verify the updated memory limit.

Additional Ways to Optimize WordPress Performance

Optimizing WordPress performance goes beyond just increasing memory limits. By implementing additional techniques, you can ensure your website runs smoothly, loads faster, and can handle more traffic without issues. Below are several ways to optimize WordPress performance for better efficiency and user experience.

1. Disabling Unused Plugins

Unused or poorly coded plugins consume memory resources and can slow down your website. Many plugins continue running background processes even when not actively used, consuming server resources unnecessarily.

How to Manage Plugins Efficiently:

  • Audit Installed Plugins: Regularly check all active plugins and deactivate the ones you don’t use.
  • Remove Redundant Plugins: Some plugins offer overlapping features. Keep only the essential ones.
  • Use Multi-Purpose Plugins: Instead of installing separate plugins for caching, security, and performance optimization, choose all-in-one solutions like WP Rocket or Jetpack.
  • Keep Plugins Updated: Outdated plugins may not be optimized for the latest PHP versions and WordPress updates, leading to inefficiencies.

2. Optimizing Images and Media Files

High-resolution images and uncompressed media files can quickly consume large amounts of server memory. Optimizing these files helps in reducing page load times and conserving memory resources.

Image Optimization Techniques:

  • Use Image Compression Plugins: Plugins like Smush, TinyPNG, and ShortPixel automatically compress images without noticeable quality loss.
  • Serve Scaled Images: Ensure that images are properly resize based on display requirements to avoid unnecessary file size.
  • Enable Lazy Loading: Delays the loading of images until they appear on the user’s screen, reducing initial page load times.
  • Use Next-Gen Image Formats: Convert images to formats like WebP, which provide better compression and faster loading times compared to traditional formats like PNG and JPEG.

3. Enabling Object Caching

Object caching improves database performance by storing frequently accessed data, reducing the need for repeated queries. This leads to faster page loads and reduced memory usage.

How to Implement Object Caching:

  • Use Caching Plugins: Plugins like W3 Total Cache, WP Rocket, and WP Super Cache enable object caching with minimal setup.
  • Enable Server-Level Caching: Some web hosts provide built-in object caching solutions such as Redis or Memcached.
  • Reduce Database Queries: Optimize database interactions by limiting unnecessary queries and keeping database operations efficient.

4. Minifying CSS, JavaScript, and HTML

Minification removes unnecessary characters, spaces, and comments from CSS, JavaScript, and HTML files, reducing file size and improving page load speed.

Best Practices for Minification:

  • Use Minification Plugins: Autoptimize, Fast Velocity Minify, and WP Rocket help automate minification.
  • Eliminate Render-Blocking JavaScript: Defer loading non-critical JavaScript to improve the initial page rendering speed.
  • Combine CSS and JS Files: Reducing the number of requests by combining multiple CSS and JavaScript files helps speed up page loading.

5. Implementing a Content Delivery Network (CDN)

A CDN distributes your website’s static files (images, CSS, JavaScript) across multiple servers worldwide, reducing latency and load times for visitors from different geographic locations.

Steps to Set Up a CDN:

  • Choose a CDN Provider: Cloudflare, KeyCDN, and StackPath are popular choices.
  • Integrate with WordPress: Many caching plugins offer easy CDN integration.
  • Enable Asset Compression: Compress CSS, JavaScript, and images before they are delivered through the CDN.
  • Monitor Performance: Use tools like GTmetrix or Pingdom to ensure your CDN is optimizing page speed effectively.

6. Cleaning and Optimizing Your Database

Over time, the WordPress database accumulates unnecessary data, including post revisions, spam comments, and transients, which can slow down website performance.

How to Optimize the WordPress Database:

  • Use Database Cleanup Plugins: WP-Optimize, Advanced Database Cleaner, and WP-Sweep remove unnecessary data and optimize tables.
  • Delete Spam and Trashed Comments: Keeping your database clean from unwanted content improves performance.
  • Limit Post Revisions: Set a limit on the number of post revisions stored in the database to prevent unnecessary bloat.
  • Regularly Backup Before Cleanup: Always create a backup before making significant database changes.

7. Upgrading to a More Powerful Hosting Plan

If your WordPress website has outgrown its hosting plan, no amount of optimization can compensate for inadequate server resources.

Choosing the Right Hosting Plan:

  • Shared Hosting: Suitable for small websites but limited in performance.
  • VPS Hosting: Offers better control and dedicated resources for growing websites.
  • Managed WordPress Hosting: Provides optimized environments for WordPress with automatic updates and caching.
  • Cloud Hosting: Scales dynamically based on traffic needs, ideal for high-traffic websites.

8. Enabling GZIP Compression

GZIP compression reduces file sizes before they are sent to the user’s browser, significantly improving load speeds and conserving bandwidth.

How to Enable GZIP Compression:

Via .htaccess File: Add the following code to enable GZIP:
<IfModule mod_deflate.c>

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript

  • </IfModule>
  • Use a Plugin: WP Rocket and W3 Total Cache enable GZIP compression with a single click.
  • Check Compression Status: Use online tools like GTmetrix to verify if GZIP is enabled.

9. Reducing External HTTP Requests

External HTTP requests from third-party scripts (such as fonts, analytics, and advertisements) can slow down website performance.

Ways to Reduce External Requests:

  • Host Google Fonts Locally: Avoid relying on external Google Fonts by hosting them on your server.
  • Disable Unnecessary Scripts: Remove tracking scripts and third-party APIs that are not essential.
  • Use Asynchronous Loading: Load external scripts asynchronously to prevent blocking page rendering.

10. Using a Lightweight Theme

Choosing a well-coded, lightweight theme can have a massive impact on your website’s performance.

Features of a Good Lightweight Theme:

  • Minimal Bloat: Avoid themes packed with excessive built-in features.
  • Optimized Code: Look for themes that use clean and efficient code.
  • Fast Load Times: Themes like GeneratePress, Astra, and Neve are known for their speed.
  • Compatible with Caching: Ensure the theme works well with caching and minification plugins.

11. Regularly Monitoring Performance

Constant monitoring ensures that your optimizations are working and helps identify potential issues before they become critical.

Performance Monitoring Tools:

  • GTmetrix: Provides data on speed and optimization techniques.
  • Google PageSpeed Insights: Analyzes and suggests improvement of web performance.
  • Query Monitor: Used for finding slow database queries and memory-hungry plugins.
  • New Relic: Offers in-depth performance analytics for WordPress websites.

Conclusion

Increasing the WordPress memory limit is necessary to maintain smooth running of the site, avoid errors, and ensure functionality. A perfectly configured memory limit ensures that WordPress executes different operations with efficiency without producing fatal errors or slowing the site during peak traffic.

By following the steps outlined in this guide, you can correctly allocate additional memory to your WordPress website so that it can execute memory-intensive plugins, handle large databases, and perform seamless content updates. This also ensures backup, media upload, and page rendering processes are not disrupted.

Moreover, adjusting your WordPress memory usage not only speeds up performance but also reduces downtime and the risk of site crashes. In case you still experience issues after increasing the memory limit, then upgrade your hosting package, implement high-end caching techniques, or consult the services of a WordPress expert for further assistance. With an optimized memory allocation, your website will run efficiently, handle more traffic, and provide a better experience for users.

If your problems persist, you can experiment with boosting your hosting plan or employing a WordPress specialist for added assistance. Provided you have a suitable memory setup allocation, your website will work optimally and handle higher levels of traffic volumes and resource requirements without hitches.

Start the conversation.

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    Recommended articles

    WordPress

    Why are the WordPress Templates Messed Up? Rocon Guide

    Nitish

    Icon

    8 Min Read

    WordPress

    How to Speed Up Your WordPress Website: Rocon Expert Guide

    Maria

    Icon

    9 Min Read

    WordPress

    Best WordPress Staging Plugin – Safely Test & Deploy Fast

    James

    Icon

    8 Min Read