Periodic functions run nodejs without memory leaks?

You need every second to save the number in mongo. How to implement it?
Wrote a simple function:

function test_save(){
 var item = new Testmodel({
 data: 123
});, item){
 setTimeout(test_save, 1000);

Tried to keep using setInterval/setTimeout, it works, but memory leak occurs due to which then all the worse. They can clean the setTimeout, while recording?

Or maybe there's something radically different that will help me to Periodically run the function without leaking memory?
July 9th 19 at 13:46
2 answers
July 9th 19 at 13:48
use pm2
July 9th 19 at 13:50
Why not use setInterval? It W it was.

Find more questions by tags JavaScriptNode.js