[RESOLVED] Error: "PHP Fatal Error: Out Of Memory"

[RESOLVED] Error: "PHP Fatal Error: Out Of Memory"

While working with PHP if you are getting “PHP Fatal error: Out of memory (allocated 49545216) (tried to allocate 77824 bytes)” error then don’t be shock. We know that it’s hard to fix this problem and especially for the large application. Sometimes we restarted apache service and this solved the issue but it’s a temporary method. If you need to solve this problem permanently then you have to increase the allocated memory for PHP. In this article we are going to explain that how to solve this problem. Let’s see how we can solve this problem....

1. If you are getting the fatal error while working with PHP then you have to make some changes in php.ini file. As you know php.ini is a configuration file which executes on server when PHP starts. Sometimes this fatal error occurs due to low memory limits, so first we have to check for the current memory limits with the phpinfo(). Create a phpinfo.php file under root directory and check for current memory limits.

By default memory limit is 8M, but in this case you have to increase the memory limits to 12M, 16M, 24M and so on with this line. This will increase your memory limit and solve this error.

Code:
memory_limit = 32M
2. If you don’t have access of php.ini file then you can also increase the PHP memory limits through .htaccess file and you don’t have to create php.ini file. You just have to add this line in .htaccess file:

Code:
php_value memory_limit 32M
3. If you are not able to follow both above steps due to some reasons then you have another option, you can also add below line in the particular PHP file which is throwing error.

Code:
ini_set(’memory_limit’, ‘32M’);
4. At last you can also increase the PHP memory limits through web-config.php file by adding below code in the file.

Code:
define('WP_MEMORY_LIMIT', '32M');
Your issue will be easily resolved from above steps but if it’s not working then you can contact your hosting provider regarding the issue.
Author
bhawanisingh
Views
22,084
First release
Last update
Rating
0.00 star(s) 0 ratings
Top