gabordemooij / redbean

ORM layer that creates models, config and database on the fly
https://www.redbeanphp.com
2.31k stars 279 forks source link

Memory leak when using R::find R::getAll #563

Closed vitale0 closed 6 years ago

vitale0 commented 7 years ago

I have a script with a loop which retrieves ~20k rows from mysql using redbean in every iteration. Every time it retrieves data the php.exe memory usage increases until it reaches the maximum allowed and exits. I'd expect that every time I retrieve data with redbean the data retrieved in the previous iteration would be discarded however apparently it's still kept in memory. I have set useWriterCache to FALSE. I have used find, findAndExport as well as getAll functions with the same results. I have tried Redbeanphp version 3.5, 4.3 and 5 with the same results.

What could be causing this behavior? Is there a way around this?

gabordemooij commented 7 years ago

not sure, I have to look into this... thnx for reporting

gabordemooij commented 7 years ago

can you provide a little script demonstrating this issue?

gabordemooij commented 7 years ago

this:

list($beans) = R::dispenseAll('bean*2000');
R::storeAll($beans);

for($i=0; $i<1000; $i++) {
    $rows = R::getAll('select * from bean limit 500');
    echo (count($rows) . ' -- ' . memory_get_usage());
    echo "\n";
}

does not cause a leak... over here

vitale0 commented 7 years ago

Updating from php 5.4.7 (xampp on windows) to the latest php 7 version included in xampp made the issue go away. On the redbeanphp website it says that php version 5.3 is required..