swoft-cloud / swoft

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

Memory leak caused by Redis #1407

Closed anhoder closed 3 years ago

anhoder commented 3 years ago
Q A
Bug report? yes
Feature request? no
Swoft version 2.0.10
Swoole version 4.5.10
PHP version 7.3.23
Runtime environment Docker

Describe the bug As I use Redis in the coroutine, the return value of memory_get_usage() gets larger and larger.

Expected behavior Memory usage will not continue to rise.

Screenshots

int(26856488)
int(26865864)
int(26875240)
int(26884616)
int(26893992)
int(26894392)
int(26895432)
int(26895832)
int(26896232)
int(26896632)
int(26897032)
int(26897432)
int(26897832)
int(26898232)
int(26899272)
int(26899672)
int(26900072)
int(26900472)
int(26900872)
int(26901272)
int(26901672)
int(26902072)
int(26902472)
int(26902872)
int(26903272)
int(26903672)
int(26904072)
int(26904472)
int(26904872)
int(26905272)
int(26906952)
int(26907352)
int(26907752)
int(26908152)
int(26908552)
int(26908952)
int(26909352)
int(26909752)
int(26910152)
int(26910552)
int(26910952)
int(26911352)
int(26911752)
int(26912152)
int(26912552)
int(26912952)
int(26913352)
int(26913752)

.......

int(27327656)
int(27328056)

Provide minimal script to reproduce the issue


    /**
     * @CommandMapping(desc="测试")
     */
    public function test()
    {
        $i = 1000;

        while (--$i) {
            sgo(function () {
                Redis::expire('test', 100);
            });

            Context::getWaitGroup()->wait();

            var_dump(memory_get_usage());
        }
     }