Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug toolbar memory leak #104

Open
yii-bot opened this issue Apr 27, 2016 · 8 comments
Open

Debug toolbar memory leak #104

yii-bot opened this issue Apr 27, 2016 · 8 comments
Labels

Comments

@yii-bot
Copy link

yii-bot commented Apr 27, 2016

This issue has originally been reported by @djeux at yiisoft/yii2#11419.
Moved here by @cebe.


I'm building a queue system for Yii2 with beanstalkd. I've got a console controller to run in a loop checking for new jobs.

    while ($run) {
            $job = $queue->listen($tubeName);

            if (null !== $job) {
                try {
                    $job->handle();
                } catch (Exception $e) {
                    $this->stderr($e->getMessage());
                    Yii::error($e->getMessage(), 'queue.' . $tubeName);
                    $job->release();
                }
            }

            if ($this->isStopped() || $this->shouldRestart()) {
                $run = false;
            }
        }

If I run it inside a loop I will constantly get increased memory usage (without handling any jobs). After cutting parts of the loop I found out that

$this-isStopped() and $this->shouldRestart() 

Is causing it. The methods simply check for a key to be present inside cache (redis)

if (Yii::$app->cache->get(self::RESTART_CACHE_KEY)) {
            $this->stdout("Restarting worker");
            return true;
        }

        return false;

So just checking cache is taking more and more memory?

Yii 2.0.7

@cebe
Copy link
Member

cebe commented Apr 27, 2016

additional comments in yiisoft/yii2#11419

@samdark samdark closed this as completed Apr 27, 2016
@samdark
Copy link
Member

samdark commented Apr 27, 2016

It's not about debug. It's about logger overall.

@cebe
Copy link
Member

cebe commented Apr 27, 2016

well, no, normal logger will flush regualry, debug toolbar logger will not.

@samdark
Copy link
Member

samdark commented Apr 27, 2016

Normal loggers aren't flushing as well.

@cebe
Copy link
Member

cebe commented Apr 28, 2016

For normal loggers all messages are sent when exportInterval is reached: https://github.com/yiisoft/yii2/blob/master/framework/log/Target.php#L104 the only exception is debug toolbar, which overrides this method.

@samdark samdark reopened this Apr 28, 2016
@samdark samdark added the type:bug Bug label Sep 3, 2017
@ghost
Copy link

ghost commented Nov 21, 2017

Has anyone found a solution to the problem? Is there another workaround than just turning off "YII_DEBUG"?

Thanks 👍

@samdark
Copy link
Member

samdark commented Nov 23, 2017

Do you have the problem in production environment?

@Deele
Copy link
Contributor

Deele commented May 17, 2018

I had similar issue. It is related to yii2-redis source being polluted with log (\Yii::trace) entries, that can't be easily controlled:

Soo it is not really debuggers problem, to catch them by default.

Only solution would be to make debugger ignore debug messages by category yii\redis\Connection::executeCommand, but there is no way to do that.

This could be solved by enhancing debugger with option to pass LogTarget configuration via module config array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants