[eluser]junkwax[/eluser]
Hi, I just installed Datamapper 1.6.0.
I do:
Code:
$c = new MyClass();
$c->select( 'id' )->limit( 2000 )->get();
and I get the PHP memory error:
Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 40 bytes) in.........datamapper.php.
When I load a smaller number of rows there is no problem:
Code:
$c = new MyClass();
$c->select( 'id' )->limit( 500 )->get();
So I looked a what's in $c and I found that $c grows proportionnaly
with the number of rows I fetch. In fact $c is 8KB X number of rows,
so for 16Mb of allowed memory, I can only fetch 16Mb / 8Kb rows (~about 2,000 rows).
If I do :
Code:
foreach( $c->all as $obj )
{
print_r($obj);
}
I see that each $obj is an instance of MyClass containing 8K of stuff that eat memory: lang string, reference to validation objects...etc. So $c->all is a big object containing thousands of 8KB MyClass instances.
It is a bug of there's something I do horribly wrong ?