Memory Leak HELP! [SOLVED] - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Memory Leak HELP! [SOLVED] (/showthread.php?tid=11020) |
Memory Leak HELP! [SOLVED] - El Forum - 08-22-2008 [eluser]Frychiko[/eluser] Hi, I have a callback function used in a function which parses large xml/csv feeds (up to around 200MB feeds), so it gets called tens of thousands of times during an import of a feed. Basically when the callback function is blank, memory usage does not increase: Code: function import_record_handler($record) BUT... when I make a single call using the active record db class, memory usage starts climbing. Code: function import_record_handler($record) Merchant_model.php below: Code: function get_temp_category_where($data) Memory keeps going rising until the memory limit is exhausted. Why is the memory not freed? cheers, Frychiko Memory Leak HELP! [SOLVED] - El Forum - 08-22-2008 [eluser]johnwbaxter[/eluser] $query->free_result() http://ellislab.com/codeigniter/user-guide/database/results.html Memory Leak HELP! [SOLVED] - El Forum - 08-22-2008 [eluser]Frychiko[/eluser] Tried that already but doesn't do anything, anyway I need to return the query so I can't do that. The actual query result doesn't really matter, ANY call to the DB active record class will leak memory...eg: Code: $this->db->where($data); Will leak memory... So, I'm guessing something the sql queries are being stored... I've tried setting $save_queries = FALSE in DB_driver.php that has no effect either. Memory Leak HELP! [SOLVED] - El Forum - 08-22-2008 [eluser]Frychiko[/eluser] Okay looks like the save_queries = FALSE is working now, must have been a cache problem. Yay! This thing should be off by default, yikes.. Memory Leak HELP! [SOLVED] - El Forum - 07-10-2009 [eluser]zutis[/eluser] Thanks Frychiko - AWSOME find!!! This has absolutely saved my a** late on a Friday! Amazing - from a script getting close to 27MB of memory usage it was back to 3MB just by changing this setting. Code: $this->db->save_queries = FALSE; What is it suppose to do? Memory Leak HELP! [SOLVED] - El Forum - 07-10-2009 [eluser]@li[/eluser] Where should I set the save_queries=false setting? Memory Leak HELP! [SOLVED] - El Forum - 07-10-2009 [eluser]garymardell[/eluser] To turn off save queries add Code: $db['default']['save_queries'] = FALSE; Into your database.php configuration file (in the configs folder). Memory Leak HELP! [SOLVED] - El Forum - 07-13-2009 [eluser]zutis[/eluser] garymardell - thats handy to know. @li - if you want to turn it off for all of the site then use the config option, if you only want to turn it off for a one off function then you can use the class variable as per my example at the top of your function. Does anyone know what it actually does - i.e. that are we loosing out on by turning it off? Memory Leak HELP! [SOLVED] - El Forum - 07-13-2009 [eluser]zutis[/eluser] just found out - it enables you to build queries between different functions. so as long as you build and execute the query in the same function then it wont affect you. Memory Leak HELP! [SOLVED] - El Forum - 10-15-2012 [eluser]Unknown[/eluser] $this->db->save_queries = FALSE; $db['default']['save_queries'] = FALSE; Neither of these settings changed the default setting. I had to manually change system/database/DB_driver.php |