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

Memory leak #29

Open
Lelya opened this issue Aug 13, 2013 · 1 comment
Open

Memory leak #29

Lelya opened this issue Aug 13, 2013 · 1 comment

Comments

@Lelya
Copy link

Lelya commented Aug 13, 2013

Hi! When I worked on this test, I have a problem - memory leak.



require __DIR__.'/../vendor/autoload.php';
$conf = require __DIR__ . '/config/apollo.php';

$loop = React\EventLoop\Factory::create();
$factory = new React\Stomp\Factory($loop);
$client = $factory->createClient($conf);

$client
    ->connect()
    ->then(function ($client) use ($loop) {
        $prevMessageCount = 0;
        $messageCount = 0;
        $loop->addPeriodicTimer(1, function () use (&$i, $client, &$messageCount) {     
        for ($i = 0; $i < 3000; $i++) {
                       $client->send('/queue/migration', 'Hello! This id message number '.$messageCount);
            echo "Posted this message: 'Hello! This id message number'.$messageCount.'\n";  
            $messageCount++;
            $kmem = memory_get_usage(true) / 1024;
            $mem  = memory_get_usage() / 1024;
            echo "Request: $i\n";
            echo "Memory: $mem KiB\n";
            echo "Real Memory: $kmem KiB\n";     
                }
        });
        $loop->addPeriodicTimer(1, function () use (&$prevMessageCount, &$messageCount) {
            $diff = $messageCount - $prevMessageCount;
            echo "Sent this second: $diff\n";
            $prevMessageCount = $messageCount;
        });
    }, function (\Exception $e) {
        echo sprintf("Could not connect: %s\n", $e->getMessage());
    });

$loop->run();

Testing my client with one listener. Different tests. When you send 100 messages per second, there is no memory leak. When posting more than 500 messages per second memory leaks in an arithmetic progression.

How can fix it?

@igorw
Copy link
Contributor

igorw commented Sep 6, 2013

Are you sure all of the 500 messages per second are being delivered? If there is an I/O bottleneck then they may be queued, leading memory to grow.

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

No branches or pull requests

2 participants