Memory Leak HELP! [SOLVED] |
[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
[eluser]johnwbaxter[/eluser]
$query->free_result() http://ellislab.com/codeigniter/user-gui...sults.html
[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.
[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..
[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?
[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).
[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?
[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.
[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 |
Welcome Guest, Not a member yet? Register Sign In |