使用套接字并以字符串形式发送帧时,内存使用率迅速增加

时间:2017-06-16 15:36:23

标签: javascript node.js sockets socket.io

我的网络应用程序在发送帧时会增加内存使用量。我试图找到解决这个问题的方法。我真正的问题是从桌面应用程序(用C#/ Unity3D编码)到javascript网页进行视频流传输。除了我的网络浏览器(chrome)中存在内存问题外,它完美无缺。我的记忆没有释放,而且迅速增加。

我编写了一个实验代码来发现为什么我的记忆没有被释放。

我每秒都会从node.js服务器套接字向web客户端多次发送一个帧。 服务器的代码如下:

#!/usr/bin/env node
 const FRAME = "{\"Data\":\"/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCADwAUADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6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Zuoy7LePK5eSZ3Y9SWzVdpgf7x/Oq+9j2/M0hZvYVooIzc2StJk9KYXJ//XUe4n+L8hTeB1Y0+VC5mPJY96aTjq1NLr65/Gm5HYH8qpIhscSPU/nSZH90/iKQH2o59qYgyfSl59BSc9zQR7mgAwfX9KOB1amnHfH4mj/PApgOyPr+NAP+zzTQTnoadluwFIB29vT9aXLe1M59f0ox7mgZJk+tGR3P61HhR1/U0uR2osFx+5cetG49gaZk+5pcn2osFx3P+TRg+oFNyfUUnOepNKwXJBnuxpMqOrA/U1HgDr+tKHVeAB+FFguSAr2H5Cl3nsKiLk8YNJlvT8zRYLkpYn0oz74+lRZY9x+VGD/eNMLkpb3/AFpCy+1RgDuPzpdyj0FKwXNAyr2GaPN9FNQeYcnCGje5/h/Ws7GvMTGVuw/M0wyP6im5f1FNOT1b8qaSE2x+9j3pCfVj+dM/E/nTTt9BTJ1HZX2P1OaNwHQfkKZvA9PwpCxPr+VMB5k9FNN3n0H50zn0/M0mD7U7CuOLt6j8qMk9SaZg56/lQVyOSfzoFccQB3/Wm5TPbNG0DsKMgdxTEG72P5UZPZaM9gCfwoyfTH1NABz7Cj8fyFHPsKMe9MNQxnuaNo9B+NHFHA7UgDKj/wCtRu9jSbh6ijcPc/QUALluw/M0fMfQfhSc44U/iaPm9R/OgAOfU0cHtSbSerH8BS7B3z+dAC5A9BSb19c/SjAHb9KUkDuKAE3HsCfrR8x6YoyPc/QUuT2X86ADB9f0o2+5/Oj5vYUm092P4UAG0f3aduHrim7R35+ppcAdABQABwOgJoLH+7j60EjuRSbl9fyoAPmPoPwpdp7sabuPZSaXLn0FMBduP/r0dOwFIQe7E0mwd+frSA//2Q==\",\"Type\":4}"
var WebSocketServer = require('websocket').server;
var express = require('express');
var app = express();
var cors = require('cors')
var http = require('http').Server(app);

app.use(function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "http://localhost:8086");
  res.header("Access-Control-Allow-Credentials", "true");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
  next();
});


http.listen(8877, function() {
    console.log((new Date()) + ' Server is listening on port 8877');

});

wsServer = new WebSocketServer({
    httpServer: http,
    path: "/images",
    port: 8877,
    autoAcceptConnections: true
});


wsServer.on('connect', function (con)
{   function myFunc () {
        con.sendUTF(FRAME);
        setTimeout(myFunc, 1000/200, 'funky');
    }

    myFunc();
    console.log("connect");

});

客户端代码如下:

 
<html>
<head>
</head>
<body>
test
<script>
var wsUri = "ws://localhost:8877/images";
websocket = new WebSocket(wsUri);
websocket.onmessage = function(evt) { onMessage(evt) };

function onMessage(message)
{
  var mes = JSON.parse(message.data); 
} 
</script>
</body>
</html>

如何释放内存?或者我做错了什么?

0 个答案:

没有答案