Swoole-src: websocket_server handShake 内存溢出

Created on 10 Jan 2017  ·  3Comments  ·  Source: swoole/swoole-src

在没有设置handShake的时候,使用内置握手协议内存有泄露;而在样例代码 https://github.com/swoole/swoole-src/blob/master/examples/websocket/WebSocketClient.php
中使用了自定义的handShake之后内存是稳定的。使用的版本是v1.9.4

Most helpful comment

使用官方的benchmark工具进行大规模压测未发现内存泄漏。请贴出你的详细测试过程。

All 3 comments

使用官方的benchmark工具进行大规模压测未发现内存泄漏。请贴出你的详细测试过程。

使用的版本是v1.9.4
测试代码使用 https://github.com/swoole/swoole-src/blob/master/examples/websocket 下面的 server.php 和 client.html,在onClose里面输出内存:
$server->on('close', function ($_server, $fd) {
echo "client {$fd} closed " . memory_get_usage() . "\n";
});

启动服务之后,浏览器间断性刷新 client.html 页面,结果如下:
[root@localhost danmu]# php server.php | grep closed
client 1 closed 256480
client 2 closed 256528
client 3 closed 256528
client 4 closed 256528
client 5 closed 256528
client 6 closed 256528
client 7 closed 256528

注释掉 server.php 里面的 handshake 回调之后,结果如下:
[root@localhost danmu]# php server.php | grep closed
client 1 closed 261880
client 2 closed 268216
client 3 closed 274552
client 4 closed 280888
client 5 closed 287224
client 6 closed 293560
client 7 closed 299896

少量请求内存上涨 并不能断定就是内存泄漏,重复进行10万次压测,观察进程的内存状况。

Was this page helpful?
0 / 5 - 0 ratings

Related issues

godtail picture godtail  ·  4Comments

jerryli1 picture jerryli1  ·  4Comments

sshymko picture sshymko  ·  3Comments

nick-zh picture nick-zh  ·  3Comments

sagesan picture sagesan  ·  4Comments