Table of Contents:
- Checking the Current Memory Limit
- How to increase the memory limit in WordPress
- 1. Edit the wp-config.php file
- 2. Editing the .htaccess file
- 3. Editing php.ini
- What to do if changes don’t work?
- Conclusion
The memory limit in WordPress determines how much memory your site can use for running PHP scripts. If the limit is too low, you may encounter errors like “Allowed memory size exhausted,” meaning your site doesn’t have enough memory to perform operations. In this article, we’ll show you how to increase the memory limit in WordPress in various ways.
Checking the Current Memory Limit
Before making any changes, it’s a good idea to check your current limit. You can do this using the built-in Site Health feature in WordPress.
- Go to Tools > Site Health.
- Click on Info and expand the Server section.
- Look for the PHP memory limit value.
How to increase the memory limit in WordPress
1. Edit the wp-config.php file
- Log in to your server using FTP or the file manager in your hosting account.
- Open the wp-config.php file (located in the root folder of WordPress).
- Add the following line to the configuration file and save the changes.
- Test your website’s functionality.
define('WP_MEMORY_LIMIT', '512M');
2. Editing the .htaccess file
- Open the .htaccess file in the root folder of WordPress.
- Add the following line to it and save the changes.
- Test your website’s functionality.
php_value memory_limit 512M
3. Editing php.ini
This option is more suited for server administrators and is usually not recommended for shared web hosting. On shared web hosting, you often do not have access to the php.ini file.
Linux (Ubuntu, Debian, CentOS, AlmaLinux, etc.)
- Apache:
/etc/php/X.Y/apache2/php.ini
- NGINX + PHP-FPM:
/etc/php/X.Y/fpm/php.ini
- CLI (Command Line Interface):
/etc/php/X.Y/cli/php.ini
(X.Y is the PHP version, e.g., 8.1)
- If you have access to the php.ini file, open it for editing.
- Find the line with the value
memory_limit
and change its value.
memory_limit = 512M
What to do if changes don’t work?
If the limit doesn’t increase despite the changes, it could be due to several factors. Some hosting providers block manual memory adjustments, especially on shared servers where a fixed limit is set. In this case, it’s advisable to contact hosting support and request a memory limit increase. Another possibility is that the changes were not applied correctly. For example, try restarting the web server (if you’re the administrator) or clearing the cache. If you’re using shared hosting, you might also consider upgrading to a better hosting plan with higher limits.
Conclusion
Increasing the memory limit in WordPress can help resolve issues related to memory shortages, especially if you’re using resource-intensive plugins or WooCommerce. However, it’s not advisable to continuously increase the memory limit, as high memory consumption could be caused by too many plugins or poorly optimized code. It’s recommended to find a balance between available memory and efficient resource usage. If problems persist even after increasing the limit, consider optimizing or reducing the number of active plugins. If issues continue, contact hosting support.
The website is created with care for the included information. I strive to provide high-quality and useful content that helps or inspires others. If you are satisfied with my work and would like to support me, you can do so through simple options.
Byl pro Vás tento článek užitečný?
Klikni na počet hvězd pro hlasování.
Průměrné hodnocení. 0 / 5. Počet hlasování: 0
Zatím nehodnoceno! Buďte první
Je mi líto, že pro Vás nebyl článek užitečný.
Jak mohu vylepšit článek?
Řekněte mi, jak jej mohu zlepšit.
Subscribe to the Newsletter
Stay informed! Join our newsletter subscription and be the first to receive the latest information directly to your email inbox. Follow updates, exclusive events, and inspiring content, all delivered straight to your email.
Are you interested in the WordPress content management system? Then you’ll definitely be interested in its security as well. Below, you’ll find a complete WordPress security guide available for free.