M
M
Michael2017-06-08 21:42:38
Yii
Michael, 2017-06-08 21:42:38

How to fix memory leak of yii2 models?

Good day.
Made a console application that runs on schedule.
A conditional selection is made. The first 100 elements. The status is completed and so on. Until all tasks for the request are completed. So with each new selection of elements, the script starts to eat memory. How to fix it?

while(true){
$task = Task::find()->select(['id'])->where(['status' => 0, 'action' => 1])->orderBy(['id' => SORT_ASC])->limit(100)->all();
// если нуль  записей то выход
// обновляю статус  на 1
}

this is in short. After receiving the data, the memory is filled. How to edit it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AlikDex, 2017-06-08
@mix_gorbachev

disable debugging and logging for the console application. All requests are first written to an array, and then dumped into files (if the log is enabled). Hence the so-called leak.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question