Why is CodeIgniter exhausing allowed memory size? Why is CodeIgniter exhausing allowed memory size? codeigniter codeigniter

Why is CodeIgniter exhausing allowed memory size?


Found the answer:

$this->load->database(); // init db connection, already in code$this->db->save_queries = false; // ADD THIS LINE TO SOLVE ISSUE

This is a lovely undocumented setting in CodeIgniter. CI apparently saves queries by default, even a certain amount of data is saved relative to insert / update queries. With the massive amount of inserts run during this import process, this memory leak became very consequential. Setting CI to not save queries solved the problem.

What threw me off was that memory_get_peak_usage() was reporting the memory usage increasing before the insert query was run, not during it (PHP bug?).

As a final reality check, I removed all the other optimization recommendations (unset, clearstatcache, etc) and verified that they had no positive impact on the memory issue.


try to use set_time_limit(0) to define the time limit of the proccess.. and between the loops you can clean the cache from mram using clearstatcache();