Skip to content

Memory leak in Model #1326

@chaiyanlin

Description

@chaiyanlin

Here is my case:
I wrote a script as a consumer of Message Queue. But I found the memory usage will be increased after called Model::find().

e.g.

<?php
namespace app\extensions\command;

use app\models\Member;


class Test extends \lithium\console\Command
{

    public $openid;

    public function run()
    {
        while(true) {
            Member::findById(3);
            sleep(1);
            var_dump(str_pad(round(memory_get_usage(true) / (1024 * 1024), 2) . "M", 7));
        }
    }
}

output:

libraries/lithium/console/li3 test --env=test
string(7) "4M     "
string(7) "4M     "
string(7) "4M     "
string(7) "4M     "
string(7) "4M     "
string(7) "4M     "
string(7) "4M     "
string(7) "4M     "
string(7) "4M     "
string(7) "4M     "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.25M  "
string(7) "4.5M   "
string(7) "4.5M   "
string(7) "4.5M   "

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions