Now all modules will be cached in this new clean cache, until you later disable Mockery again. The new cache is temporary, and is discarded when Mockery is disabled.
When loading a module via require, its reference is also pushed to the array under children property of the module where the require function was used.
Even after mockery swaps back the old cache and deletes the reference to the new temporary cache there are still references to all loaded modules in parents Module.children array so the memory used by those modules can't be freed.
When loading a module via
require
, its reference is also pushed to the array underchildren
property of the module where therequire
function was used. Even after mockery swaps back the old cache and deletes the reference to the new temporary cache there are still references to all loaded modules in parentsModule.children
array so the memory used by those modules can't be freed.