I hosted my website on Linux server. While I accessed the Contact us Page of the site I got the below error:
Allowed memory size of 33554432 bytes exhausted (tried to allocate 43148176 bytes) in php
It has given the full path of the php file like public_html//plugins/system/xyz.php and also the line number at which the error has occurred. In my case it was line number 79
This was annoying. But the solution to fix the above issue is very simple.
You need to open the file which throws the above error. Here it's xyz.php. And go to the line number mentioned in the above error(79). Just above this line add the code mentioned below:
ini_set('memory_limit', '-1');
Instead of restricting the memory usage of the server, this line will unlimit the memory use of the server. Here "-1" will give the required memory. But if you are sure how much memory is required, then you can restrict with that value also
Eg:
ini_set('memory_limit', '128M');
Here we are restricted it to 128MB. You can mention it based on the requirement.
That's it. Happy Coding
Allowed memory size of 33554432 bytes exhausted (tried to allocate 43148176 bytes) in php
It has given the full path of the php file like public_html//plugins/system/xyz.php and also the line number at which the error has occurred. In my case it was line number 79
This was annoying. But the solution to fix the above issue is very simple.
You need to open the file which throws the above error. Here it's xyz.php. And go to the line number mentioned in the above error(79). Just above this line add the code mentioned below:
ini_set('memory_limit', '-1');
Instead of restricting the memory usage of the server, this line will unlimit the memory use of the server. Here "-1" will give the required memory. But if you are sure how much memory is required, then you can restrict with that value also
Eg:
ini_set('memory_limit', '128M');
Here we are restricted it to 128MB. You can mention it based on the requirement.
That's it. Happy Coding
No comments:
Post a Comment