swoft-cloud / swoft

🚀 PHP Microservice Full Coroutine Framework
https://swoft.org
Apache License 2.0
5.58k stars 786 forks source link

task中循环使用QueryBuilder,内存一直增加 #302

Closed youyoubao closed 6 years ago

youyoubao commented 6 years ago

循环代码:

c64db419daeeabd58bb772d738e63044

(循环执行,内存使用量越来越多。如果一直循环下去,内存肯定会爆掉)

尝试的解决办法: 1:关闭日志,每次增长的内存会少一些 2:修改Swoft\Db\QueryBuilder中的execute方法,最后一行修改为:

$ret = Db::query($sql, $this->parameters, $instanceName, $this->className, $this->getDecorators());
$this->clearDecorators();
return $ret;

经过两处修改,每次内存的增量已经很少。但如果循环执行,还是会超出内存限制。

huangzhhui commented 6 years ago

swoft-db release. https://github.com/swoft-cloud/swoft-db/releases/tag/v1.1.14