search

Home  >  Q&A  >  body text

node.js - nodejs performance optimization issues

//定时任务
setInterval(function() {
    startCron();

}, 1000*20);


function startCron(){
    let cron = new Cron();
    cron.startCron();
}

For example, if cron is executed regularly, when will the memory of cron be released? If a certain attribute of cron is a larger array. For example, cron.data, do I need to manually set cron.data = [] to release memory every time cron ends the task?
If I don’t release it manually, will cron never release it?

I have recently encountered performance problems. Are there any good tools for nodejs to detect them?

阿神阿神2733 days ago613

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-05-31 10:43:22

    No need to release it manually, it should be released automatically after startCron is run. The execution context where startCron is located will be released after it is executed. If you want to test performance, there seem to be quite a few. You can check it out on cnode. There seems to be an easy module written by Chinese people. You can use process.memory to test first

    reply
    0
  • Cancelreply