magento/magento2 — pull request #484 by rgranadino (2014-01-30 09:24:19+00:00)
Title: Calling clear / removeAllItems / removeItemByKey on Magento\Eav\Model\Entity\Collection\AbstractCollection  does not remove model from protected _itemsById array

When paginating through EAV collection models (e.g. customers or products) calling the `clear` method does not reset the `$_itemsById` protected member. This causes the list of objects referenced in that array to grow exponentially. When working with large collections (e.g. for exports or reports) this can lead to exhausting the amount of memory that a script is allowed to allocate.

NOTE: This issue exists in mage1 as well.

I also went ahead and updated `removeAllItems` and `removeItemByKey`.

I'd be happy to write a test case but there doesn't appear to be a base one at this time. I'd be helpful if you could point me in the right direction (another similar test case) as this functionality relies on loading entities.

On a side note, whats the difference supposed to be between `clear` and `removeAllItems` ?