Ticket Details

Memory Issues with Document Object

ENHANCEMENT Ticket (in progress)

###What happened:
Iterating through a document object via Model::find('all') with a large dataset (say 9,000 results) from MongoDB causes a fatal memory issue. There are no issues iterating through a result from MongoCollection::find() 

For instance:

{{{
    $conditions = array(
        'date_created' => array(
            '$gt' => new MongoDate(strtotime($this->request->data['min_date'])),
            '$lte' => new MongoDate(strtotime($this->request->data['max_date']))
    ));
    $orders = Order::find('all', array('conditions' => $conditions));
    foreach ($orders as $order) {
        ...do something...
        ...fatal error happens here...
    }
}}}

[Here is the stack trace](http://pastium.org/view/ec9b22862f1eea719e62e1d728cc7653)

###What was expected:
For large datasets the document object shouldn't cause a fatal memory issue.

on 11.16.10 reported by: fitzagard

Updates

on 11.16.10 by fitzagard
  • type was changed to bug
  • priority was changed to normal
on 11.21.10 by jperras
  • owner was changed to jperras
  • status was changed to in progress
on 03.07.11 by nate
  • owner was removed
  • type was changed to enhancement
Changing this to an enhancement, as it's not actually broken.
on 05.02.11 by edmunc
On a probably related note – it is also 40 to 100 times slower to iterate over a DocumentObject when comparing it to doing the same without any li3 classes. It takes more than a second to iterate over even a thousand objects, which could become a problem in many projects.

Example code [in pastium](http://pastium.org/view/68fbf3f742f443158870c0fbc7104e56)

I am currently trying to profile the example using xhprof, I'll post if I find anything.