Skip to content

Understanding WP_MEMORY_LIMIT: what it does and how to change it

WordPress, just like any other application needs memory to do its thing. It needs the server’s memory. The WP Memory Limit, not to be confused with WP Max Memory Limit, is a constant inside WordPress that defines the maximum amount of memory that WordPress can use.

By default, WordPress sets this limit to 40M for a single site and 64M for a multisite. However, some themes and plugins may require more memory to function smoothly.

What Does WP Memory Limit Allow You to Do?

Section titled “What Does WP Memory Limit Allow You to Do?”

Having enough memory available to any given WordPress installation is crucial. If WordPress is not allowed to use the amount of memory it needs, certain functions will fail to run fully. Resulting in fatals and all kinds of annoying errors.

More specifically, this is what having ample memory defined in the WP Memory Limit safeguards:

  • Better Plugin and Theme Compatibility: Some plugins and themes demand more memory. By increasing the WP Memory Limit, you ensure that these tools run without errors. This enhances the overall functionality and user experience of your site.
  • Efficient Content Management: With a higher memory limit, you can manage more extensive content libraries. This includes large media files, multiple posts, and complex page structures. It ensures that your WordPress admin dashboard remains responsive.
  • Enhanced Performance: Increasing the WP Memory Limit can in some cases actually improve your WordPress site’s performance. More memory allows your site to handle more processes simultaneously. This is particularly beneficial for sites with heavy traffic or resource-intensive plugins.
  • Limited by Server Capabilities: Even if you set a high WP Memory Limit, your server’s physical memory limits it. Shared hosting environments may impose restrictions. Always check with your hosting provider before making changes.
  • Potential Performance Issues: Setting the WP Memory Limit too high can cause performance issues. It might lead to server crashes if WordPress cannot handle the allocated memory.

There are different options available to you to change the WP Memory Limit. Method 1 is the one to try first, but some hosting environments need method 2 or 3. Check with your hosting company if the first option doesn’t work.

  1. Access Your WordPress Directory: Use FTP or your hosting control panel.
  2. Locate wp-config.php: This file resides in the root directory.
  3. Edit the File: Open it using a text editor.
  4. Add/Modify the Memory Limit: Insert the following line:
define('WP_MEMORY_LIMIT', '128M');
  1. Save and Upload: Save your changes and upload the file back to the server.
  1. Access php.ini: This file is usually in the server’s root directory.
  2. Edit the File: Open it with a text editor.
  3. Change the Memory Limit: Add or modify the line:
memory_limit = 128M
  1. Save and Restart: Save your changes and restart your web server.
  1. Locate .htaccess: This file is in your WordPress root directory.
  2. Edit the File: Open it with a text editor.
  3. Add the Memory Limit: Insert the following line:
php_value memory_limit 128M
  1. Save and Upload: Save your changes and upload the file back to the server.

Understanding and managing WP Memory Limit is crucial for your WordPress site to perform everything it needs to optimally. By increasing the limit, you enhance your site’s capabilities. Use the methods outlined to adjust the memory limit as needed. Always aim for a balanced setting to avoid potential issues.

By following these steps, you can ensure a smoother, more efficient WordPress experience.

The Site health screen shows two related values under Details:

  • Memory limit (in the WordPress panel): the WP_MEMORY_LIMIT WordPress is set to.
  • PHP memory limit (in the Server panel): PHP’s memory_limit on a normal page load, after WordPress has applied WP_MEMORY_LIMIT.

When the PHP memory limit is below 128 MB, Scanfully shows the warning PHP memory limit is 64 MB (with your value) in the Performance area. WordPress raises PHP’s limit to WP_MEMORY_LIMIT when that is higher, so setting WP_MEMORY_LIMIT to 128M usually clears it, as long as your host lets WordPress raise the limit. Otherwise raise memory_limit with method 2 or 3. A limit of -1 (no limit) never counts as too low.