How to Fix Memory Limit Issues in WordPress & PHP

November 13, 2024 / WodPress

In this guide, you will explore how to resolve memory limit issues in WordPress and PHP.

WordPress is a versatile content management system, that allows you to quickly build a professional website or blog. However, the default memory limit, typically set to 32MB, may fall short as your site grows in plugins or traffic. When your WordPress site surpasses this limit, you may encounter an error such as:

Fatal error: Allowed memory size of 33554432 bytes exhausted

In response, many users either reach out to their hosting provider or try to adjust their “.htaccess” file, which can lead to accidental problems if not handled carefully. Always remember to back up your WordPress files before making any changes.

Steps to Increase the WordPress Memory Limit:
  1. Modify the wp-config.php File: To increase the WordPress memory limit, locate the “wp-config.php” file in your WordPress directory, accessible via SSH or the File Manager in cPanel. Add this line to boost the memory:
    define(‘WP_MEMORY_LIMIT’, ’64M’); Adjust this limit to 32MB, 40MB, 64MB, or 128MB, depending on your requirements.
  2. Contact Your Hosting Provider (Shared Web Hosting) For shared hosting plans, you might want to ask your hosting provider to increase the memory limit on your behalf.
  3. Increase PHP Memory Limit  Since WordPress operates on PHP, increasing PHP’s memory limit is essential. Locate the php.ini file (typically in the /etc/ directory on cPanel servers) and adjust the memory_limit parameter: memory_limit = 64M If you run multiple WordPress sites, ensure the memory allocation is sufficient for all installations. For instance, if two blogs each require 64MB, set the PHP memory limit to 128MB: memory_limit = 128M
  1. Refresh Your Site After completing these adjustments, refresh your WordPress site to see if the memory issue has been resolved.

Implementing the above-outlined steps should help resolve memory errors, allowing your WordPress site to run smoothly as it expands. Moreover, if you face any difficulty with this process, get in touch with our technical team.

Read also How to Fix the ‘Critical Error on Your Website’ in WordPress

Leave a Reply

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