5/5 - (1 vote)

Sometimes, when working, you may have faced the dreaded “Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted” message. This error occurs when a PHP script exceeds the memory limit set by the server. While it can be frustrating, there are several solutions to fix this issue and get your website up and running smoothly again. So, today, we will introduce to you some effective methods to overcome this error and optimize your PHP memory usage.

Understanding the Error Fatal error: allowed memory size of 134217728 bytes exhausted

The “Allowed Memory Size Exhausted” error is a result of a PHP script consuming more memory than what is allocated by the server. By default, PHP sets a memory limit of 128 megabytes (134217728 bytes), which may not be sufficient for certain resource-intensive applications or scripts.


How to fix the error Fatal error: allowed memory size of 134217728 bytes exhausted

Increase PHP Memory Limit

One of the simplest ways to address this issue ‘Fatal error: allowed memory size of 134217728 bytes exhausted’ is by increasing the PHP memory limit. This can be done by modifying the PHP configuration file, usually called “php.ini.” Locate this file on your server and open it with a text editor. Look for the following line:

memory_limit = 128M

Change the value to a higher limit according to your requirements, such as “256M” or “512M”. Save the file and restart your web server for the changes to take effect. However, note that not all hosting providers allow users to modify the PHP configuration file directly.

Modify .htaccess File

If you don’t have access to the php.ini file, you can try modifying the .htaccess file in your website’s root directory. Add the following line to increase the memory limit:

php_value memory_limit 256M

Save the file and refresh your website to see if the error is resolved. Keep in mind that some hosting providers may restrict the use of php_value directives in the .htaccess file.

Adjust Memory Limit via wp-config.php (WordPress)

For WordPress users, the memory limit can be modified through the wp-config.php file. Open the file in a text editor and add the following line before the “That’s all, stop editing!” comment:

define('WP_MEMORY_LIMIT', '256M');

Save the file and check if the error has been resolved. WordPress also offers plugins like WP Memory Usage that can help identify memory-intensive plugins and themes.

Disable or Limit Plugins/Modules

In case you are running a content management system (CMS) like WordPress or Drupal, disabling or limiting resource-intensive plugins or modules can help alleviate the memory issue. Identify any plugins or modules that consume significant memory and consider alternatives or optimization options.


Final words

To sum up, facing “Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted” can be frustrating, but it’s not an insurmountable problem. By following the steps outlined in this blog post, you can effectively resolve this issue and ensure that your PHP scripts run smoothly without memory limitations.

If you have any questions, please leave your comment below. What’s more? Don’t forget to access the collection of various responsive free WordPress themes here.

Leave a Reply

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

Joomla! Update The way to smoothly upgrade Joomla! 4 to Joomla! 5 Read this guide
Happy Lunar New Year! Enjoy your purchase with 50% OFF on today! code: LUNARNEWYEAR50 More Details