title: Why is memory consumption getting larger and larger in a foreach cycle?
body: <p>I have a big amount of data which is being processing using CLI.</p>
  
  <p>In the scipt the data goes through a foreach cycle.</p>
  
  <p>But on every iteration the memory consumption is getting larger and larger.</p>
  
  <p>Why is this happening? Every var is getting reassigned in the loop, so there must not be memory leaks. Although I tried to set a var null on the end of every iteration, it didn't help.</p>
  
  <p>In the loop I use objects (ActiveRecord) and work with a DB.</p>
  
  <p>At the beginning the script works really fast (about 10 iterations per second), by the end its performance is less than 1 iteration per second.</p>
  
  <p>Thanks.</p>