Due to the robust design, unfortunately, Magento may confront with memory intensive issue. The error may be like this PHP Fatal error: Allowed memory size of 45108864 bytes exhausted (tried to allocate 157556 bytes) in path/to/file.php
Users, however, are able to adjust the memory limits in order to solve the memory errors. This tutorial will show you how to fix those errors by adding codes into 2 files separately.
Step 1. Login to the Account Management Panel and under your account name, click the cPanel button to be redirected to the cPanel. Then, open File Manager.
Step 2. Click on Settings in the top right corner of the working space and navigate to root folders of your Magento Installation.
Step 3. Go to the index.php file and have a right click. Select Code Edit then click Ok.
Quick note: If you have access to FTP or SFTP, you can navigate to the same file location to make changes to files using Filezilla or CuteFTP, Winscp.
Step 4. Add this line of the code right after <?php tag in index.php:
1 | ini_set("memory_limit","768M"); |
You can set the value more than 768M to ensure that there’s enough PHP memory for handling Magento tasks
Step 5. Click the Save Changes button in the upper right corner of working space:
Step 6. Return to the File Manager to go to app/Mage.php file. Right click and select Code Edit as previously.
Step 7. Add the following code to the first line:
1 | ini_set("memory_limit","768M"); |
Step 8. Click the Save Changes button in the upper right corner of working space:
Step 9. Check if the issue is fixed, if not, you should also change php memory limit in two files: php.ini and .htaccess file
For php.ini, go to /etc/php.ini, edit file and add the following lines:
1 2 | memory_limit = 7686M max_execution_time = 18000 |
For .htaccess, go to your Magento installation folder, edit and add the following lines:
1 2 | php_value memory_limit 767M php_value max_execution_time 18000 |
After everthing is done, restart your apache to apply changes using:
1 | service httpd restart |
Step 10. Reload your website to ensure there is no further memory issues exist.
That comes to the end of the tutorial. If you have any further questions on this topic, please comment below to let us know.