08-04-2015, 07:15 PM
I was browsing and noticed this error message on
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:
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:
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:
NOTE that some coder will inform you to set the memory limit to '-1' which means UNLIMITED.
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:
( this may not work if you are on a shared hosting, if you get error 500 after saving, just go back and edit the same file .htaccess and remove the comment the line with php_value like this #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:
*END***
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?
[To see links please register here]
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:
Hidden Content
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:
Hidden Content
NOTE that some coder will inform you to set the memory limit to '-1' which means UNLIMITED.
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:
Hidden Content
( this may not work if you are on a shared hosting, if you get error 500 after saving, just go back and edit the same file .htaccess and remove the comment the line with php_value like this #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:
Hidden Content
*END***
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?