Skip to content

Instantly share code, notes, and snippets.

@yorkie
Created May 26, 2014 15:25
Show Gist options
  • Save yorkie/fb35faaadc8bc21268fe to your computer and use it in GitHub Desktop.
Save yorkie/fb35faaadc8bc21268fe to your computer and use it in GitHub Desktop.
gc example
var http = require('http');
function request(callback) {
var option = {
host: 'www.baidu.com',
port: 80,
path: '/',
method: 'GET'
};
http
.request(option, request)
.on('error', request)
.end();
console.log('ping');
}
for (var i = 0; i < 5; i++) {
request();
}
var http = require('http');
function noop() {
// TODO
}
function request(callback) {
var option = {
host: 'www.baidu.com',
port: 80,
path: '/',
method: 'GET'
};
http
.request(option)
.on('error', noop)
.end();
console.log('ping');
}
setInterval(function() {
for (var i = 0; i < 5; i++) {
request();
}
gc();
}, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment