Hello,
I need to iterate 2kk db records.
I simplified my code to this:
<?php
foreach ($videoIds as $videoId) {
$video = null;
$video = Video::findFirst($videoId->id);
echo 'after memory usage: ' . memory_get_usage();
echo PHP_EOL;
gc_collect_cycles();
And I get:
after memory usage: 275166496
after memory usage: 275176504
after memory usage: 275186472
after memory usage: 275196216
after memory usage: 275206480
after memory usage: 275216920
after memory usage: 275226872
after memory usage: 275236368
after memory usage: 275246720
after memory usage: 275256296
after memory usage: 275266128
It means, each findFirst appends ~10kb to memory. All fields in model are defined as public. As you see in my code, I try to nullfy and gc collect, but it doesn't helps to me.
I tried to disable snapshot and dynamic update, but it didn't helped:
<?php
class Model extends PhalconModel
{
public function initialize()
{
$this->keepSnapshots(false);
$this->useDynamicUpdate(false);
}
}
Any ideas?
Regards