Skip to content

Instantly share code, notes, and snippets.

@cworsley4
Created March 24, 2015 04:30
Show Gist options
  • Save cworsley4/458aa035f97672794e9f to your computer and use it in GitHub Desktop.
Save cworsley4/458aa035f97672794e9f to your computer and use it in GitHub Desktop.
Shows the memory leak found in io.js (https://github.com/iojs/io.js/pull/1244)
var superagent = require('superagent');
var url = 'https://localhost:3000';
var complete = false;
var maxReqs = 150;
var activeReqs = 0;
function run() {
console.log('Max [%d] | Active [%d]', maxReqs, activeReqs);
if (activeReqs < maxReqs) {
activeReqs++;
superagent
.get(url)
.end(function () {
console.log('Finished request');
activeReqs--;
});
}
}
setInterval(run, 12);
var fs = require('fs');
var https = require('https');
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('help world');
});
https.createServer({
key: fs.readFileSync('./key.pem'),
cert: fs.readFileSync('./cert.pem')
}, app).listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment