I\'m writing a codeigniter application, upon doing a query i get hit with the following fatal error.
Fatal error: Allowed memory size of 134217728 byt
If anybody else has this problem:
Make sure your memory size in php.ini has an M after the number.
I had 512 in there....when I changed it to 512M .....no more problem.
z
Your code looks fine. Check if some function is getting called repeatedly.
You could use
ini_set('memory_limit', '-1');
as a temporary solution. or just increase the memory_limit
Chceck you php.ini
file. If it is in the below form,
memory_limit=8G
Change that in the form of MB
memory_limit=8192M
You can also do it in your code like
ini_set('memory_limit', '8192M');
The problem occurs because a private method kept calling itself over and over again until the allocated memory is exhausted and the script stops execution
private function get_member_data($tid){
return $this->get_member_data($tid);
}
This is a stupid human error, the above method should have been re-written as below
private function get_member_data($tid){
//Call to model method
return $this->invest->get_member_data($tid);
}
Sorry, and thanks everyone.
If you want to know where the memory goes you should look into PHP memory profiling: PHP memory profiling
Personally I would just increase the PHP max_memory to 256MB and see if it's enough ;)
Put this line on your codeigniter's index.php. So it will be affected for whole project.
ini_set('memory_limit', '-1');
Note: This is just a quick fix. This bug has not been resolved in php itself.