How can one release a Node.js module during runtime in order to save memory or improve the overall performance.
My application dynamically loads modules in Node.js d
To unload a script, you can do this:
delete require.cache['/your/script/absolute/path'] // delete the cache
var yourModule = require('/your/script/absolute/path') // load the module again
So if you have plugin modules, you can watch those files' change, then dynamically unload(delete the cache), then require that script again.
But make sure you are not leaking memory, you can re-assign the changed module to the old variable. Here is a handy tool that you can check the memory: node-memwatch .
Good luck!