kakserpom / phpdaemon

Asynchronous server-side framework for network applications implemented in PHP using libevent
http://daemon.io/
GNU Lesser General Public License v3.0
1.53k stars 231 forks source link

Memoy leaks #8

Closed Emmerman closed 14 years ago

Emmerman commented 14 years ago

I wrote some simple tests with rtep+memcache+mongo and face a memory leak problem after each session. Unfortunately, I still can't find source of this leaks.

kakserpom commented 14 years ago

Thank you for report. Please provide the sources.

kakserpom commented 14 years ago

I mean that I need the sources to reproduce the problem.

Emmerman commented 14 years ago

class Example extends AppInstance { public $memory;

public $cache;

public function init()
{
    Daemon::log('Example up.');
    $self = & $this;
    $this->memory = memory_get_usage();

    $this->cache = Daemon::$appResolver->getInstanceByAppName('MemcacheClient');
    $RTEP  = Daemon::$appResolver->getInstanceByAppName('RTEP');

    $RTEP->operations['memget'] = function($session, $packet, $args, & $response) use ($self)
    {           
        $key = $args[1];
        $self->cache->get($key, function($answer) use ($session, $key, $self)
        {

            $session->send(array('type' => 'event', 'event' => array(
                'key'   => $key,
                'value' => $answer->result
            )));

            $self->status();
        });
    };
}

public function status()
{
    $memory = memory_get_usage();
    if ($memory !== $this->memory)
    { 
        $diff = $memory - $this->memory;
        Daemon::log('Memory '.$memory.' ('.($diff > 0 ? '+' : '').$diff.')');
        $this->memory = $memory;
    }
}

}

I have about 300-400kb leaks after 1k connections (1 operation per connection).

kakserpom commented 14 years ago

I still can't figure out where is the leak.

Emmerman commented 14 years ago

I think issue #14 have fixed it. But I will test it later.

kakserpom commented 14 years ago

Closed.