1

I am new to codiginter .When i load it gives memory error with following message what should i do now

Allowed memory size of 134217728 bytes exhausted (tried to allocate 65488 bytes) in C:\xampp\htdocs\ci\system\database\DB_driver.php on line 1968

SE.JUNAID
  • 31
  • 10
  • add the error text – Ori Marko Aug 01 '17 at 06:34
  • 2
    Hello and welcome to StackOverflow. Please take some time to read the help page, especially the sections named ["What topics can I ask about here?"](http://stackoverflow.com/help/on-topic) and ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask). And more importantly, please read [the Stack Overflow question checklist](http://meta.stackexchange.com/q/156810/204922). You might also want to learn about [Minimal, Complete, and Verifiable Examples](http://stackoverflow.com/help/mcve). – kishor10d Aug 01 '17 at 06:46
  • Add related code to question that led to the error. Controller, Model, anything custom written that is included within that request. – Tpojka Aug 01 '17 at 12:25

1 Answers1

0

You have created an infinite recursion scenario. Look:

  • Database_Model and Session_Model extend Model.
  • When you instance Database_Model, the constructor inherited from Model will instance two additional objects on the constructor, $this->db and $this->session.
  • Those new objects also inherit from Model, so they will also instance their own Database_Model and Session_Model.
  • And this goes on infinitely...

Solution:

  • The correct way is to edit your php.ini file. Edit memory_limit to your desire value.

    As from your question, 128M (which is the default limit) has been exceeded, so there is something seriously wrong with your code as it should not take that much.

    If you know why it takes that much and you want to allow it set memory_limit = 512M or higher and you should be good.

    However try to avoid huge memory use, if the number of users are going to be more.

  • Moreover, If you monitor your server, you will see that it is now probably using up most of the RAM and even swapping to disk.

    You should probably try to track down the exact bug in your code and fix it.

Hope this is helpful

Ahmad
  • 445
  • 5
  • 15
  • No need to extend memory_limit, I think he have to check the queries which he is firing. – kishor10d Aug 01 '17 at 06:42
  • yep , he should check again his code , that's what i added now in my answer @kishor10d – Ahmad Aug 01 '17 at 06:47
  • how you come to know about his recursive scenario. He didn't provide anything as input. – kishor10d Aug 01 '17 at 06:47
  • this is what happens with most of PHP codiginter @kishor10d – Ahmad Aug 01 '17 at 06:48
  • check [Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (CodeIgniter + XML-RPC)](https://stackoverflow.com/questions/561066/fatal-error-allowed-memory-size-of-134217728-bytes-exhausted-codeigniter-xml) @kishor10d – Ahmad Aug 01 '17 at 06:50