no, there is only one Server instance. Just add some console.log()s at various places to get an idea what is happening.
On Thu, Mar 14, 2013 at 1:16 AM, utan <[email protected]> wrote: > Isn't every user that connect starting a new instance of the class? > > if I destroy the socket instance I am effectively destroying just the > user class it started ? > > I was thinking every user is different and running his own instance of > the class.. am I right? > > > > On Mar 13, 4:00 pm, Arian Stolwijk <[email protected]> wrote: > > Usually you don't really care, because node/V8 handles memory. > > > > Also from what I see in your code it just creates the Server instance and > > directly calls the connect method. There is absolutely nothing special > > about that. > > > > Then you have socket.io. If I recall correctly you add "connection" > event > > listeners on the socket.io server, that are called with the socket > object. > > That socket object can emit the "disconnect" event. > > > > One thing I'm sure about is that you shouldn't destroy the socket.ioserver > > object, especially not in the socket disconnect event, because when one > > socket is disconnected, the others should still continue to work. It > > actually would keep working because with "delete this.server" you only > > remove the reference from the Server object to the socket.io server > object. > > (I think, if it would be correct, "this" in the disconnect event listener > > doesn't even refer to the Server instance). > > > > Besides that it's hard to say what would be the problem without further > > insight. > > > > > > > > > > > > > > > > On Wed, Mar 13, 2013 at 11:40 PM, utan <[email protected]> wrote: > > > So you mean, I should manually delete the instance this.server , I am > > > confused completed... > > > > > On Mar 13, 9:41 am, Arian Stolwijk <[email protected]> wrote: > > > > No idea, generally if you want that the garbage collector picks it > up, > > > you > > > > should make sure that there are no references to it anymore. > > > > > > I don't really know any reason why MooTools Classes should be any > > > different > > > > from traditional JavaScript inheritance (using var Foo = function(){ > ... > > > } > > > > Foo.prototype.bar = ... stuff). > > > > > > On Wed, Mar 13, 2013 at 5:33 PM, utan <[email protected]> > wrote: > > > > > Ok, appreciate for reading it.. > > > > > > > On Mar 10, 10:11 pm, utan <[email protected]> wrote: > > > > > > Hi guys, > > > > > > > > I have node application using socket.io and motools server side, > > > > > > problem is that I seem to be having memory leak and since is > server > > > > > > side I'm not really sure.. > > > > > > > > When a user connect a new instance of the class is created, see > this > > > > > > code bellow: > > > > > > > > // initiate the server > > > > > > require('./node_modules/mootools'); > > > > > > var io = require('./node_modules/socket.io'); > > > > > > > > var Server = new Class({ > > > > > > Implements : [process.EventEmitter], > > > > > > > > initialize: function(port) > > > > > > { > > > > > > this.serverPort = port; > > > > > > this.server = null; > > > > > > // let's connect > > > > > > this.connect(); > > > > > > }, > > > > > > connect : function(){ > > > > > > // connect to socket io > > > > > > this.server = > io.listen(this.serverPort ,{ > > > > > log: false }); > > > > > > > > client.on('disconnect', function() { > > > > > > delete this.server;// doubt should i > delete > > > this > > > > > object after user > > > > > > has disconnected? > > > > > > }); > > > > > > } > > > > > > > > }); > > > > > > > > // initiate the server > > > > > > var app = new Server(80); > > > > > > > > My question is , is the class and it's object destroyed when user > > > > > > disconnect or socket in this case, or we should manually destroy > the > > > > > > class and or objects.. (I am still in the process of learning > more, > > > > > > bear with me). > > > > > > > > Should I delete this object on disconnect like so : delete > > > > > > this.server; > > > > > > > > How is the class and objects taking care in server side with > motools? > > > > > > > > Appreciate your help. > > > > > > > -- > > > > > > > --- > > > > > You received this message because you are subscribed to the Google > > > Groups > > > > > "MooTools Users" group. > > > > > To unsubscribe from this group and stop receiving emails from it, > send > > > an > > > > > email to [email protected]. > > > > > For more options, visithttps://groups.google.com/groups/opt_out. > > > > > -- > > > > > --- > > > You received this message because you are subscribed to the Google > Groups > > > "MooTools Users" group. > > > To unsubscribe from this group and stop receiving emails from it, send > an > > > email to [email protected]. > > > For more options, visithttps://groups.google.com/groups/opt_out. > > -- > > --- > You received this message because you are subscribed to the Google Groups > "MooTools Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- --- You received this message because you are subscribed to the Google Groups "MooTools Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
