mfncooper / mockery

Simplifying the use of mocks with Node.js
Other
1.1k stars 60 forks source link

useCleanCache: true - leaks memory #51

Closed sjuchno closed 7 years ago

sjuchno commented 8 years ago

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.