Webpack 5 - Memory Leak
See original GitHub issueBug report
What is the current behavior?
When I make a change in my web app and Webpack compiles, memory usage seems to increase. If I keep making changes and Webpack keeps re-compiling, memory usage will continue to climb. In a large project I work in, it takes about 10 compilations until Webpack crashes with a “Allocation failed - JavaScript heap out of memory” exception.
If the current behavior is a bug, please provide the steps to reproduce.
Please see the minimal repo I created to reproduce the issue: https://github.com/smparsons/webpack-memory-leak-issue. The instructions to reproduce are on the README.
What is the expected behavior?
I would expect some kind of garbage collection to happen in between compilations.
Other relevant information: webpack version: 5.0.0-beta.15 Node.js version: 11.10.1 Operating System: macOS Catalina Version 10.15 Additional tools:
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)

Top Related StackOverflow Question
Do not use any kind of hash in the filename during development when using webpack-dev-middleware. Each compilation will create a new file as filename changes. Just like files will pile up on disk, they will pile up in memory as the webpack-dev-middleware stores output files in memory.
This one does the trick, right?