So I want to make a program that would get data from a web api every 15 minutes and process it. That process would be endless (untill the program is closed). I've experimented with timeouts but my PC quickly runs out of memory (24GB of RAM), so my code is obviously a very bad way to do it.The processing and gathering data part of code is done and works fine, what isn't working is the endless loop part. My take on this problem was essentially this:
for (i = 0;; ++i) {
setDelay(i);
}
function setDelay(i) {
setTimeout(function(){
//More code goes in here.
console.log(i);
}, 1000);
}
Surely there must be a better way to execute a chunk of code every X amount of minutes endlessly without flooding you PC's RAM. Any ideas?