Release memory after mysql query
OK, lesson learned. To whomever might experience the same issue:
CI insert queries can also be saved and take up memory.
In my setup I had:$remoteDB which was my remote connection I used to retrieve the dataand$userDB which was the connection to my local DB, where I inserted the data. This one had
$userDB->save_queries = TRUE;
And took up my memory without me seeing any variables being set.
after setting this to FALSE before the loop, I could handle as much data as I wanted without draining the memory. And I get to keep the query metadata.