Table of contents

WordPress is a powerful content management system that powers over 40% of websites. It is a versatile platform that can be used for everything from personal blogs to corporate websites, e-commerce stores, and more. However, sometimes, WordPress users might encounter the issue of running out of memory while using the platform. In this article, we will discuss how to increase the memory limit in WordPress.

What is the memory limit in WordPress?

Before we dive into the details of increasing the memory limit in WordPress, it is essential to understand what memory limit means. In simple terms, memory limit refers to the maximum amount of memory that PHP scripts are allowed to use on a web server. PHP is a programming language used to build dynamic websites, and it is the language that WordPress is built on.

how to increase php memory limit

By default, WordPress has a memory limit of 64MB, which is enough for most websites. However, some plugins, themes, and custom code can quickly consume this memory, resulting in the infamous “Fatal Error: Allowed memory size exhausted” message. This error message indicates that WordPress has reached the memory limit and needs more memory to run.

How to check your WordPress memory limit?

Before you can increase your WordPress memory limit, you need to know what your current memory limit is. There are several ways to check your WordPress memory limit, but the easiest way is to use a plugin. Here are the steps to follow:

Step 1: Install and activate the WP Memory Usage plugin.

Step 2: Navigate to the Dashboard > Tools > WP Memory Usage page.

Step 3: The plugin will display your current memory limit, as well as the amount of memory currently used by WordPress.

Once you know your current memory limit, you can proceed to increase it if necessary.

how to increase php memory limit

How to increase your WordPress memory limit?

There are several ways to increase your WordPress memory limit, depending on your web hosting environment. Here are the three most common methods:

Increase WordPress memory limit via wp-config.php

One way to increase your WordPress memory limit is by adding a line of code to your wp-config.php file. The wp-config.php file is located in the root directory of your WordPress installation. Here are the steps to follow:

Step 1: Log in to your website’s cPanel or FTP client.

Step 2: Navigate to the root directory of your WordPress installation.

Step 3: Locate the wp-config.php file and open it with a text editor.

Step 4: Add the following line of code to the file just before the line that says, “That’s all, stop editing! Happy blogging.”

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

This code increases the memory limit to 256MB. You can replace 256M with any value you like, depending on your needs.

how to increase php memory limit

Step 5: Save the changes to the file and upload it back to your server.

Increase WordPress memory limit via .htaccess

If your web hosting environment uses Apache, you can also increase your WordPress memory limit by adding a line of code to your .htaccess file. Here are the steps to follow:

Step 1: Log in to your website’s cPanel or FTP client.

Step 2: Navigate to the root directory of your WordPress installation.

Step 3: Locate the .htaccess file and open it with a text editor.

Step 4: Add the following line of code to the file just before the line that says “RewriteEngine On.”

php_value memory_limit 256M

This code increases the memory limit to 256MB. You can replace 256M with any value you like, depending on your needs.

Step 5: Save the changes to the file and upload it back to your server.

Increase WordPress memory limit via php.ini

Depending on the configuration of your server, you can use the following ways to set the upload limit for media in WordPress. If these settings do not work, it is best to contact your provider and ask them to make the settings.

1st option: php.ini

upload_max_filesize = 1024M

post_max_size = 1024M

max_execution_time = 1000

2nd option: .htaccess

php_value upload_max_filesize 50M

php_value post_max_size 50M

php_value max_execution_time 600

php_value max_input_time 600

3. Option: wp-config.php

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

set_time_limit(600);

4. Option: functions.php

@ini_set( ‘upload_max_size,’ ‘1024M’ );

@ini_set( ‘post_max_size,’ ‘1024M’);

@ini_set( ‘max_execution_time’, ‘1000′ );

Conclusion

Increasing PHP limit in WordPress will allow you to upload high dimensions files on your website without any risk. In the end it is important that your websit will run smooth and fast so it will offer the best user experience for the visitors.

Feel free to check our Youtube channel or to check our blog to find out more informations about Kubio Builder.

Related articles

How to Create a WordPress Travel Website in 2022

wordpress media library