mfncooper / mockery

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

fix: remove cached modules completely from require cache in disable() #71

Open wenboyu2 opened 5 years ago

wenboyu2 commented 5 years ago

Problem: We noticed memory leak with require cache when using mockery.enable({useCleanCache: true}). disalbe() doesn't clean up the cache completely.

Solution: Remove module references from m._cache as well as the module's parents' children.

pklingem commented 5 years ago

@mfncooper we've verified this PR fixes the memory leak we were seeing. Any chance of getting this merged?