Answer the question
In order to leave comments, you need to log in
Fetch eats a lot of RAM. How to fix?
var humanize = require('humanize');
var request = require('request');
function fetch(url, c) {
request(url, function(err, resp, body) {
if (err) {
c(err);
return;
}
c(err, resp, body)
});
}
function callback(err, resp, body) {
var memory = process.memoryUsage();
console.log("Memory usage: " + humanize.filesize(memory.heapUsed) + " / " + humanize.filesize(memory.heapTotal));
fetch('тут_url_запроса', callback)
}
function Number() {
fetch('тут_url_запроса', callback);
}
setInterval(Number, 350)
Answer the question
In order to leave comments, you need to log in
Your fetch calls the callback passed to it, and the callback calls fetch again, and so on in a circle.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question