The allowed memory size of bytes exhausted error is common to users of CMS systems such as WordPress, and Joomla. It display this message when the server encounter an internal error and cannot deliver the page you request. The only reason that this error appear is because you have exceeded the default memory limit.
Increase the PHP Memory Resource
The best solution to solve this error is to increase the php memory resource to a level that enables the application to work again. You will have to use the code editor to launch the php.ini file in your cPanel. The php.ini is located in the public_html directory. Once you have located the php.ini file, you must locate the memory_limit line and increase the limit to 1 GB. The level of memory limit you need to increase will depend on how much memory it needs. You should allocate slightly more than the exhausted memory level to ensure everything will work smoothly.
However, you should not allocate too much memory as it can take up a lot of the hard disk space on the server. You can set the memory resource to different levels from 32 M to 4097 M depending on the server that you are using. Before setting to a specific memory level, you must check to see if your server gives you permission to use that amount of dedicated memory. After making changes to the line, you must save the changes. The changes will only become effective after the php.ini file is made recursive.
Make the PHP.INI File Recursive
By default, the PHP settings in the php.ini file is not recursive. It is important to set the php.ini to recursive so that the changes will affect all the child folders. You can make the php.ini recursive by simply adding the code
in the .htaccess file. The code tells the server where the php.ini file is situated and that you want it to be made recursive. The username part should be substituted with your cPanel username. You can create a php.info page to run a test and see if the changes has take effect. The Loaded Configuration File should show the php.ini file that you want to make recursive.
Checking to Make Sure the Error Message Does not Display Anymore
If you have done it correctly, the error will no longer be displayed on the site when you revisit the URL again. One way to check whether the memory_limit is updated properly is to create a new text file called info.php in the same directory and add the code <?php phpinfo() ;?>. Next, you can view the page in the browser by entering the URL. You have to make sure that you specify the directory where you place the .info.php in the URL. If you still see the error, it could be that there is a setting on the software that is preventing the change you made on the php.ini file to take effect. If you don’t know how to add the code into the php.ini file, you can contact the web hosting company’s customer support department to help you on this.
Getting Rid of Unused Plugins
There could be some processes running on your site that is taking up a lot of memory. For example, if you run a WordPress blog, you should delete plugins that you have no use as these plugins are consuming the php memory. Sometimes, it won’t help by just increasing the memory limit so you have to optimize the code.
In conclusion, you must always pay attention to the PHP settings on your web hosting account if you are running a site that uses PHP. You must always make sure that the PHP settings are configured to the optimal settings to prevent facing the “allowed memory size” error.