Search (advanced search) | ||||
Use this Search form before posting, asking or make a new thread.
|
08-04-2015, 10:15 PM
(This post was last modified: 08-04-2015 10:24 PM by sevceg.)
Post: #1
|
|||
|
|||
SOLVED: Fatal error: Allowed memory size of 8388608 bytes exhausted on BBHF
I was browsing and noticed this error message on BBHF today, I thought I should share a solution to it to help others currently facing this problem.
Many website owners runs into this error and sometimes it seems as if it's fixed but just to find out that it is not permanently fixed. If you are getting an error such as: Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 8192 bytes) in /blah/blah Below find out how to fix this, either temporarily or permanent solution
The reason is that the application/script running at the moment this error occurred does not have enough memory to complete the given task, hence reporting a fatal error message. Solutions: There are many quick fixes, but I preferred a permanent solution. Solution #1. If you have access to your php.ini file, the simple solution is to location the memory_limit = in your php.ini file and increase the limit. e.g change : Code: memory_limit = 64M Solutioin #2 if you do not have access to system php.ini file (because you have a shared hosting account ) then you may be able to create a php.ini in your home directory and add the following to it: Code: memory_limit = 256M In general this is a bad practice and should not be used on any production server. Solution #3. If your hosting allow you to modify .htaccess in the root folder of your website. add the following to the top your .htaccess Code: php_value memory_limit 256M Save it. Permanent solution: Since the more visitors on a website uses more resources, (memory etc) dynamically. Thus, a quick fix of increasing the memory will not be a good idea for a website that receive constant traffic. I quickly wrote this piece of code to automate the process. In my code, I set the memory not to drop than 30% ( 30 percent ), this way every time the system memory drop to 30%, the code will quickly add another 90% (90 percent) to it. **BEGIN**** PHP Code: <?php Save the above file with any filename, in my case it's saved as memory_reset.php How to use it? =============== Just include saved file any header or footer file of your php script, this way if you want to disable it by adding a comment notation infront of the include statement. e.g. usage: open your footer.php or the header.php and type the following: include_once 'memory_reset.php'; Save it. You are good to go. To disable it: just add a comment notation infront of the include statement. // include_once 'memory_reset.php'; Save it. Your setting is gone. Let me know if this help?
*nix command is sexy: locate |find |grep |touch | mount | unzip | dig | clear | zip | umount
|
|||