Код: Выделить всё
foreach($updates as $update){
echo 'START_DB:' . memory_get_usage()."\n";
$sql = "SELECT *
FROM positions
WHERE relation_id = {$request['id_relation']}
AND positions_date = {$update}";
$position = $this->connection->createCommand($sql)->queryAll();
unset($position);
echo 'FINISH_DB:' . memory_get_usage()."\n";
}
FINISH_DB:7779984
START_DB:7779984
FINISH_DB:7781104
START_DB:7781104
FINISH_DB:7782224
START_DB:7782224
FINISH_DB:7783344
START_DB:7783344
FINISH_DB:7784464
START_DB:7784464
FINISH_DB:7785584
START_DB:7785584
FINISH_DB:7786704
...
...
...
FINISH_DB:184015872
START_DB:184015872
FINISH_DB:184017008
START_DB:184017008
FINISH_DB:184018144
FINISH:183853032
Память растет очень быстро.
Если использовать mysqli:
Код: Выделить всё
foreach($updates as $update){
echo 'START_DB:' . memory_get_usage()."\n";
$sql = "SELECT *
FROM positions
WHERE relation_id = {$request['id_relation']}
AND positions_date = {$update}";
$result = $this->link->query($sql);
unset($result);
echo 'FINISH_DB:' . memory_get_usage()."\n";
}
START_DB:6230776
FINISH_DB:6230776
START_DB:6230776
FINISH_DB:6230776
START_DB:6230776
FINISH_DB:6230776
START_DB:6230776
FINISH_DB:6230776
START_DB:6230776
FINISH_DB:6230776
START_DB:6230776
FINISH_DB:6230776
START_DB:6230776
FINISH_DB:6230776
START_DB:6230776
FINISH_DB:6230776
FINISH:6070752
Память держится всегда одной и той же.
Замечу, что исполнение скрипта идет по крону в классе наследованном от CConsoleCommand
В чем может быть проблема? Может быть это ошибка в yii?