Created
July 17, 2015 10:57
-
-
Save neich/97743a806fc76ff06932 to your computer and use it in GitHub Desktop.
Memory leak when coap request get error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///// | |
///// Execute with: node --max-old-space-size=6 --max_semi_space_size=1 coap-debug.js | |
///// | |
var coap = require('coap') | |
var count = 0 | |
function get() { | |
var nErrors = 0 | |
var n = count++ | |
if (count % 10 == 0) { | |
console.log('Heap used: ' + process.memoryUsage().heapUsed) | |
} | |
console.log("Starting GET number " + count) | |
coap.request({host: "aaaa::212:7402:2:202", pathname: "/test/path", method: 'GET'}) | |
.on('response', function (res) { | |
res.on('data', function () {}) | |
res.on('end', function () { | |
console.log('GET completed ' + n + '') | |
}) | |
}) | |
.on('error', function (e) { | |
nErrors++ | |
console.log('Request error <' + nErrors + '> :' + e.toString()) | |
}) | |
.end() | |
} | |
setInterval(get, 1000) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment