Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is a problem with your client js:</p> <pre><code>client.on('end', function() { console.log('end'); client.end() }) </code></pre> <p>This event will happen <em>after</em> the connection ends, which you do by calling <code>.end()</code>... so it doesn't make any sense to call <code>.end()</code> in the end event. Also, you are not closing the connection at all:</p> <pre><code>var client = net.connect({ host: host, port: port }, function(i) { return function() { //'connect' listener var num = i; console.log('client connected ' + num); this.end() //Close the connection } }(i)); </code></pre> <p>After fixing that I can run your code without exceptions, and it did not leak for me. </p> <p>Server code:</p> <pre><code>function getUsed() { return process.memoryUsage().heapUsed; } var startedWith; var net = require('net'); var server = net.createServer(function(client) { client.on('data', function() {}); client.on('end', function() { console.log("end"); }); }); server.listen(8124, function() { startedWith = getUsed(); }); setInterval(function() { gc(); }, 13); setInterval(function() { gc(); console.log(getUsed() - startedWith); }, 250) </code></pre> <p>Run with node 0.10 <code>$ node --expose-gc server.js</code></p> <p>Client code:</p> <pre><code>var net = require('net'); var host = 'localhost', port = 8124 for (var i = 0; i &lt; 1500; i++) { var client = net.connect({ host: host, port: port }, function(i) { return function() { //'connect' listener var num = i; console.log('client connected ' + num); this.end(); } }(i)); client.on('end', function() { console.log('end'); }) } </code></pre> <p>Run with node 0.10 <code>$ node client.js</code> after server is running.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload