I was reading some of the answers at Stack Overflow about lazy loading and manual unloading of modules in NodeJS, one of the answers quoted
Node is single threaded so the memory footprint of loading a module is not per-connection, it's per-process. Loading a module is a one-off to get it into memory.
Which is a fair enough explanation, but then there is a question that is there some point of time when the old unused modules (that were earlier required and are no longer used in execution) cleared from cache? How does the Garbage Collector works in this case?
UPDATE:
This answer shows how to manually remove a module from cache, which also indicates that module caching might be different from regular in-memory objects
var name = require.resolve('moduleName');
delete require.cache[name];