Choose another country or region to see content specific to your location and shop online.
USA

4 ways to increase your WordPress memory limit

Picture of William Bacchus
William Bacchus

Published: September 1, 2023

Last updated: September 1, 2023

Table of Contents

How to increase your WordPress memory limit

WordPress is an incredibly versatile platform that accommodates a vast array of themes, plugins, file formats, and other software. Nevertheless, it’s not uncommon to come across the WordPress memory limit error when attempting to upload these resources.

Thankfully, there are effective methods to troubleshoot this issue. By optimizing the PHP memory allocation on your WordPress website, you can seamlessly expand your site’s content and help to support its growth.

In this article, we will explore four easy ways to increase the WordPress memory limit, enabling you to overcome any errors that may be impeding your website’s performance. So, let’s delve into these solutions and ensure a smooth experience for your WordPress site.

What is the WordPress memory limit?

The PHP Memory Limit is a configuration setting in PHP that specifies the maximum amount of memory a PHP script is allowed to use during its execution. Increasing the memory limit can enhance the performance and stability of your website, especially if you have a lot of plugins, themes, or complex functionality. When your website reaches the memory limit, it may result in slow loading times, error messages, or even crashes.

It is important not to get this confused with your storage limit. This is the amount of software, extensions and other downloads which can go onto your website. This includes everything from themes and plugins, to files, images and videos.

Consider the PHP Memory Limit as a busy kitchen in a popular restaurant. Each PHP script is a chef, busy preparing a meal. The memory limit is akin to the available counter space in the kitchen. When a chef (PHP script) is working, they need space on the counter (memory) to prepare the meal (execute the script).

If the counter space (memory limit) is too small, chefs (scripts) might run out of room, causing a disruption in the workflow. By increasing the counter space (PHP memory limit), you allow more chefs (scripts) to work simultaneously. However, expanding the counter space (increasing the memory limit) can be costly and might be unnecessary if the chefs (scripts) can work more efficiently.

So, while it’s possible to increase the counter space (PHP memory limit) in your kitchen (server), it’s usually better to find ways to help your chefs (scripts) work more efficiently. This would mean optimizing your PHP code to use as little memory as possible, just like a chef who organizes their workspace to use as little counter space as possible.

Now you should have a good understanding of what the PHP memory limit is, so let’s take a look at four methods that will help to increase it.

Why have I recieved the WordPress memory limit error?

Encountering WordPress errors can be frustrating, but understanding their causes can help you solve them efficiently. WordPress often provides vague error messages, such as the 500 internal server error. This error occurs when your server runs out of memory, which can happen when uploading media or installing themes or plugins. To avoid this issue, consider increasing your memory limit and upgrading to a more advanced hosting plan. While higher-tier plans offer more resources, it’s still important to minimize memory usage by uninstalling unnecessary plugins and optimizing performance. By taking these steps, you can prevent memory-related errors and enhance your WordPress experience.

1) Edit the wp.config file to increase the memory limit

In WordPress, you can adjust the current memory limit by modifying the wp-config.php file through the wp_memory_limit variable. However, it is important to note that this limit might be lower than the memory provided by your hosting plan.

If this is the case, you can resolve the error by making changes to the wp-config.php file. It is recommended to create a backup of your website before proceeding, as modifying code carries a certain level of risk.

To edit the wp-config.php file, you will need to establish an FTP connection to your server using an FTP client like FileZilla. Here is a brief tutorial on connecting with FileZilla:

  1. Open the FileZilla application and navigate to File > Site Manager.
  2. If this is your first time connecting via FTP, select File > Site Manager > New Site.
Site manager filezilla

To begin, you have the option to input details about your website, including your FTP username and password. In case you are unsure of your FTP credentials, you can usually locate them within your web hosting account.

Once you’ve provided the necessary information, FileZilla will establish a connection with your site and present a comprehensive view of all its files. Within the application, simply navigate to the root folder of your website to proceed.

To access the wp-config.php file, navigate to the designated folder and right-click on it. From the context menu, choose the option to View/Edit the file. This will open wp-config.php in your default text editor. Within the file, locate the line of code that contains the phrase “WP_MEMORY_LIMIT”. It should resemble the following:

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

If this line of code already exists, you will need to increase the allocated memory. For instance, you can modify it from 32M to 256M.

In case you do not find this code snippet in the file, you must add it. Place the following code above the line that reads

/* That's all, stop editing! Happy publishing. */:

Then add in this above it

:define( 'WP_MEMORY_LIMIT', '256M' );

2) Edit the PHP.ini file to increase the memory limit

Editing the PHP.ini file is another method to increase the memory limit in WordPress. The PHP.ini file is responsible for setting the default configuration for any application that requires PHP. When someone visits your WordPress site, PHP runs on your server and looks for instructions in the PHP.ini file, including the current WordPress memory limit.

If your hosting provider uses cPanel, you may have the option to edit the PHP.ini configuration through cPanel. This can be done using tools like MultiPHP Manager, MultiPHP INI Editor, or PHP Config. However, not all hosts provide this capability.

For instance, if you are hosting your site with The Elite Web Co., you can access the full cPanel dashboard and use a tool called MultiPHP INI Editor from the Advanced tab.

It allows you to modify the PHP.ini file and adjust the memory limit as needed. Once the tool has been opened, you can adjust the memory limit.

If your hosting provider does not provide an in-dashboard PHP.ini editor, you may still be able to edit the PHP.ini file using FTP.

After establishing a connection, go to the root directory in the FileZilla window and find the PHP.ini file.

Open the file and search for a line that contains “memory_limit=”. You can then raise this value and save the modifications.

To apply these changes, you must restart your server. Once the server is operational again, you should no longer encounter the WordPress memory limit error.

3) Edit the .htaccess file to increase memory limit

The .htaccess file holds significant importance as a configuration file for web hosts that utilize Apache (a popular choice among many hosts). It plays a crucial role in managing various aspects of your website’s configuration, including memory limits.

One of the key advantages of .htaccess is that it enables you to communicate instructions to your server without the need to modify server configuration files directly. This feature proves particularly useful when you cannot access your PHP.ini file.

To access the .htaccess file, establish an FTP connection with your server, as previously mentioned. From there, you can navigate to your site’s public_html directory, where the .htaccess file resides.

Next, you want to open the file and paste in the following code snippet below the line reading “END WordPress”

php_value memory_limit 256M

Ensure that you save the changes made once done.

4) Upgrade your Web Hosting plan

If you find yourself running into memory limitations on your website, it’s important to understand that your hosting plan plays a significant role. Each plan comes with a limited amount of resources, which can restrict your site’s memory capacity. If you’ve exhausted all troubleshooting options and are still facing errors, it’s possible that your current plan is no longer sufficient for your needs.

To check your memory allocation, refer to your web host’s website or hosting panel. Alternatively, reach out to your provider for assistance. If you suspect that you’ve reached your resource limit, it may be time to upgrade your plan. This could involve moving to a higher tier or switching to a different type of plan, such as a Virtual Private Server (VPS) or a Dedicated Server.

Consider exploring different hosting providers as well. When searching for a new host, pay attention to the memory allocation offered in each plan. Aim for a provider that offers a default memory limit of 256 MB or higher. Opting for a flexible provider that allows easy resource scalability can also help prevent future memory limit errors.

Sign up for free news, tips & offers

Your email is safe with us, we don't spam.

Picture of William Bacchus
William Bacchus
Will joined the Elite team in 2021. He has a background in content writing as well as a keen interest in media journalism. His interests include taijutsu and a immense passion for film and television. He aims to inform as many people as he possibly can about the vast and often confusing nature of web design!

Leave a Reply

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

Reseller login

If you’re a reseller, use the button below to sign in. (your reseller account is separate to your regular account)

New customer

New to ELITEWEB.Co? Create an account to get started today.

Registered users

Have an account? Sign in now.

Sign up to our newsletter for the latest news + a Free WordPress Guide

NEWSLETTER