简体   繁体   中英

dnode memory leak?

I want to test the performance of dnode, so I try to send a string from client to server, and server call back client with the same string. The memory usage of server always increasing, the server crashed after 691 calls. Was it my javascript code wrong? Any idea to solve this problem? Thanks alot!

client:

// client:  
var DNode = require('dnode');  
var sys = require('sys');  

DNode(function () {
    this.clientCall = function() {
        sys.puts("... client call!");
    };
}).connect("192.168.1.201", 6060, {reconnect:1000}, function (remote, con) {  
    sys.puts("server Connected!");

    var cnt = 0;

    var str = '';
    for(var i=0; i<1024 * 1024; ++i)
    {
        str += 'a';
    }

    function func2() {
        remote.func1(str, function(str) {
            cnt ++;
            sys.puts("" + cnt + ": " + str.length);
            if(cnt < 1000)
            {
                process.nextTick(function () {
                    func2();
                });
            }
        });
    }

    process.nextTick(function () {
        func2();
    });

});  

sys.puts("Client running!")

server:

// server:  
var DNode = require('dnode');  
      var sys = require('sys'); 

var server = DNode(ChatServer).listen(6060);

function ChatServer (client, con) {
    var cnt=0;

    this.func1 = function (str, f) {cnt++;
        sys.puts(cnt);
        f(str)
    };
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM