Meet Our New Innovation

Grab It at Flat 50% OFF

How To Change PHP Memory Limit WordPress

How to Increase PHP Memory Limit in WordPress (3 Methods)

Let’s say you are trying to install a WordPress plugin or add PHP files to your website. But your website fails to load and shows a fatal error message that tells you, “You don’t have enough memory.”

However, you don’t have any idea why it happens and how to solve this problem in the right way. Don’t worry you are not the only one who faces this issue.

So, in the following guide, we are going to let you know how you can change the PHP memory limit in your WordPress website, which will solve the issue. Before that, let’s understand what the PHP memory limit is and the reasons for the WordPress Memory Exhausted Error.

Let’s get started.

What Is the PHP Memory Limit?

PHP is a server-side scripting language especially used for web development. It helps you process and execute the PHP codes to operate themes, plugins, and core files on WordPress websites.

The PHP memory limit refers to the maximum amount of memory within which a WordPress site has to execute its operations. By default, WordPress sets the PHP memory limit of 32MB, but some web hosting providers increase this to 64MB for all users.

The default memory limit (32MB) is good enough for websites working with small plugins and limited media files. If your website has lots of programs, your web server will require more memory to function the site.

If you want to build an eCommerce website or want to use a page builder like Elementor to design, your website will surely require increasing the memory limit. Because those large-sized plugins will need more memory to work flawlessly well.

What Happens Due to Insufficient PHP Memory Limit

One common problem arising from insufficient PHP memory limit is the “Allowed memory size exhausted” error, like the image below. This error usually occurs when the PHP script tries to allocate more memory than what is available within the defined limit.

Insufficient PHP Memory limits causes the Allowed memory size exhausted error
(Source: WPBeginner)

Another problem that can arise is the “Out of memory” error. This can occur while the script tries to execute memory-intensive operations or deal with large amounts of data.

All these can result in degrading the overall website performance. As a result, you’ll face slower execution times and increased response times in running web applications.

How to Increase PHP Memory Limit in WordPress (3 Ways)

Three methods of how to increase PHP memory limit in WordPress

Hope by now you know the theoretical background of the WordPress Memory Exhausted error. Now, you must step up to solve this problem. There are several ways you can increase the PHP memory limit in WordPress. We’ll explain them in this section.

Method 1: Increase PHP Memory Limit Via FTP

To improve the PHP memory limit of your website, you need to edit your wp-config.php file. You can easily access your wp-config.php using an FTP server like FileZilla. It’s free, so you can download and use it to access your website’s backend files.

Learn what is an FTP server and how it works. After finishing the FileZilla setup, you can connect your website to it. Then, you just need to find and open the wp-config.php file.

Use FileZilla to get wp-config file
Source: Kinsta

Now it’s time to add the below code snippet to the wp-config.php file (paste it at the end of the code).

define( ‘WP_MEMORY_LIMIT’, ‘256M’ );

Don’t forget to save the file after editing.

Now you have defined your website’s PHP Memory Limit of 256MB. That is perfect for all websites.

Note: You can increase the memory limit to 512MB based on your need. If you aren’t used to FTP, you can follow any of the below methods.

Method 2: Increase PHP Memory Limit Via cPanel

Log in to your cPanel account using the right credentials. Find and click on the File Manager option.

Go to File Manager in cPanel to increase PHP memory limit

Then navigate to the public_html > your website > wp-config.php.

Open the wp-config.php file to increase PHP memory limit

Copy and paste the following code to the respective section on the page.

define( 'WP_MEMORY_LIMIT', '256M' );
Edit wp-config file

Then, save the file.

Method 03: Increase PHP Memory Limit Via PHP.ini

If your cPanel has the MultiPHP INI Editor option, you can increase the memory limit from here as well. Most hosting servers allow this option only to VPS and dedicated hosting subscribers. Let’s first check if this option is available on your cPanel.

Log into your cPanel again. Find MultiPHP INI Editor under the Software section. Click the option if it’s available.

Open MultiPHP INI Editor

Select the domain for which you’ll configure the PHP INI basic settings.

Select your domain to configure PHP INI basic settings

Set a new limit for the maximum upload file size. You may set 128M, 256M, or anything you want. Press the Apply button before closing the page to save the settings.

Set new limit for the maximum upload file size

Thus, you can easily increase the PHP memory limit in your WordPress websites.

FAQ on How to Increase PHP Memory Limit in WordPress

Hope you are satisfied with the tutorial. You may visit this post to learn WordPress website maintenance checklists. Now, we’ll answer some common questions related to the topic of how to increase the PHP memory limit in WordPress. that may poke your mind.

What is the maximum PHP memory limit?

The maximum PHP memory limit for your website may vary depending on your hosting platform. By default, this is set to 32M, 64M, 128M, or 256M. You may increase its limit to even more if your hosting platform allows.

What does cause the WordPress Memory Exhausted Error?

1. Insufficient PHP memory limit
2. Memory-intensive plugins or themes
3. Large data process overloading the system
4. Inefficient code or memory leaks

Can increasing the PHP memory limit negatively affect a WordPress site?

If you unnecessarily allocate more memory limit for your WordPress site, this can consume more memory usage, straining server resources. So, it’s crucial to maintain a perfect balance between your needs and the memory limit.

In how many ways, can I increase the PHP memory limit?

You can increase the PHP memory limit in numerous ways. But the easiest ones are:

1. Using an FTP file
2. Using the wp-config.php file
3. Using the MultiPHP INI Editor

Is it a must to increase the PHP memory limit when upgrading the PHP version?

No, it’s not mandatory to increase the PHP memory limit when upgrading the PHP version.

Conclusion

All WordPress websites don’t need to increase their PHP memory limit from 32MB to 256 MB. If your website has a lot of heavy files and extra plugins that cross the default memory, then you should increase it.

Some hosting providers do not allow you to increase the PHP memory limit. If it happens, you should contact your hosting provider to resolve this issue.

There are some other common WordPress errors that can also prevent your website from loading. You can check and fix them by reading the below article.

Learn: How to Solve WordPress Website Not Loading Issues

If you like this helpful guide, don’t forget to share this blog on your social channels. You can also join our newsletter to get helpful WordPress & Elementor guides for free.

Subscribe to our newsletter

Get latest news & updates on Elementor

Share this post

Related Post

Leave a Reply

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