Thursday, 16 March 2017

How to reset all variables in memory using Nodejs

Maybe my question is not exactly correct, but basically, I need to know the easiest way to reset all of my variables within my node js application using the npm package node cron (https://www.npmjs.com/package/node-cron).

The package works great... My function is running on the scheduled interval, but each time it runs it does not release the previous scheduled tasks variables from memory. Essentially it appears that I am getting each iteration added into the last.

What is the best practice for releasing everything from memory so it does not keep the old data on each time the task runs.

Example: (run the function every minute)

var cron = require('node-cron');

cron.schedule('* * * * *', function(){
  myFunction();
});

As mentioned above the function myFunction() runs each time via the node-cron library. However, the variables inside this function appear to not get released from the memory on each run of the scheduled cron task.

Any ideas?

Thanks!



via jremi

No comments:

Post a Comment