-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Webpack4 has memory leak in development mode #6929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@zD98 Please create minimum reproducible test repo |
project git: https://github.com/zD98/webpack-memory-test |
Having same issue on webpack 4.5.0. |
Unchanged module string should be compiled and cached once. Unchanged modules are compiled every time in rebuilding Now. So does the CachePlugin have some errors ? |
I just upgraded from 3.10.0 to 4.5.0 and I'm seeing this sporadically in development:
The only change I made to my |
@colinrcummings can you create minimum reproducible test repo? |
@evilebottnawi, see above. I was able to reproduce it with this test repo by making "multiple operations that change code quickly" as @zD98 indicates. |
This is the list of changes between the two modes https://medium.com/webpack/webpack-4-mode-and-optimization-5423a6bc597a so I'd disable each and see if it fixes anything. I'm slowly going through them now but for us even production eventually blows up. I imagine more people don't run production in development and so maybe it hasn't been spotted. |
What might be the easiest way to fix this is to disable both modes but I can't find anything in the documentation for that. |
|
@briandipalma problem not in mode, problem inside plugin, need detect there and fix it |
@evilebottnawi do you have some suggestions about detecting which plugin has problem? I can't get any ideas from the source code. |
The use case where it's blowing up for us is during testing with webpack-karma. We launch ~40 sets of tests with a new compiler serially eventually it gets to ~30 in the list and node blows up. This worked OK with Webpack 3 and webpack-karma for Webpack 3. I don't understand how this leak could work though, as we launch a new Karma Server per package (https://github.com/caplin/caplin-dev-tools/blob/master/karma-test-runner/src/utils.js#L90-L120) so that means a new |
@zD98 just enable/disable loaders/plugins and run profile plugin |
Same problem here. It seems that it happens after I upgraded webpack to 4.6.0
|
@CarterLi Can you create minimum reproducible test repo? |
I've figured out our major problem, it was Karma. PR here karma-runner/karma#2981 I think there are other leaks still present but they are smaller. It looks like my issue wasn't the same as this one anyway. |
same when I use development mode. |
I am having the same issue when building for production using webpack. |
We need minimum reproducible repo, without this it makes no sense to write about the fact that you have a problem. Thanks! |
Good point, sorry for not providing a repo, it's private (work-related). Configuration is hardly reproducible.
|
Got the same issue when developing with hot reload. |
Guys please read #6929 (comment) again, we can't solve this problem because in pure usage |
Ok, here is a minimal test case for the leak that I am experiencing. I extracted the example from a much larger project that I am working on. The problem here seems caused by a third-party plugin, It appears that webpack is keeping |
@lorenzodallavecchia Thanks! |
I found the leak in Karma by using the Chrome dev tools and I'd recommend others to do the same. Starting node with |
@briandipalma if you found memory leak please create issue in |
I was talking about the leak in this comment #6929 (comment) I'd suggest people use the Chrome tooling to trace down the leaks themselves it's doable with some patience. |
hi...maybe there are some conflicts between |
I did some more investigation on my leak involving Long story short: it is probably not webpack's fault. compiler.hooks.compilation.tap("test", compilation => {
const context = Object.create(this, {
compilation: { value: compilation },
});
let fn = (function() {
console.log("Making compilation");
}).bind(context);
compiler.hooks.make.tap("test", fn);
}); As you can see, it is registering a I will be reporting this to the plugin author since I guess this is not something a plugin should do, isn't it? |
After i've commented out After i've tried to add TerserPlugin to optimization (or plugins) section, and it fails again, so obvious that there is a problem with source maps library so i stick with inline-cheap-source-map option, at least it makes hot reload possible. |
|
Same issue without plugins, just loaders. |
Something to note here: |
I cloned the ReactJs source code and ran the command I am still getting the error
Here's the full log
Can anyone please help me with this? TIA. |
I'd mention that it's currently not possible to run webpack-dev-middleware without using a memory-based FS, which means that long-running webpack dev servers (or short-running ones in large projects) will have to be restarted regularly, or will need a custom development server. My team ended up doing the latter simply because of the size of our codebase. |
@salemhilal That's not ideal, of course. It is not unreasonable to expect webpack-dev-middleware to prune no longer needed files when their hash changes. |
@evictor Potentially, but as I understand it, it can be non-trivial to tell when things like autogenerated bundles containing split chunks are no longer needed, since these modules may only be named by hash. Or, what if your app is loaded in the browser, a file is edited which causes an async bundle to get renamed, but then in the browser, your code requests the old async chunk? It would error out unexpectedly because the requested bundle was pruned, which could seem more like a misconfiguration than expected behavior. It could be a whole lot more effective to allow users to just opt out of using |
I think we can fix this behavior for next major release |
Thanks for the well thought out reply, Salem. I think the error in the
browser is preferable to the OOM — error could be caught and tailored to be
informative, too, e.g. suggesting refresh of page.
Disk space also not a bad idea 👌🏻
On Thu, Jul 11, 2019 at 4:51 AM Evilebot Tnawi ***@***.***> wrote:
@salemhilal <https://github.com/salemhilal> That's not ideal, of course.
It is not unreasonable to expect webpack-dev-middleware to prune no longer
needed files when their hash changes.
I think we can fix this behavior for next major release
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6929?email_source=notifications&email_token=AAMLRPFFDDUAF77ARNWNYXLP64NFVA5CNFSM4EYN4HC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZWON4Q#issuecomment-510453490>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAMLRPAUAVWW6OTI6M3LPULP64NFVANCNFSM4EYN4HCQ>
.
--
- Zeke
|
[chunkhash] might cause gc problems: webpack/webpack#1914 see also webpack/webpack#6929
Think that issue related only to chunk's splitting interface/plugin, so, we should free old chunks which are not important after recompilation. To reproduce we should just multiplie save diff. changes, for example 5-6 changes in one second, memory gonna be freed by gc, but not at all, for example normal vue app with a lot of components gonna take near ~300mb, if we gonna save changes it's gonna raise to 500(and cleared by gc, to 300mb again), if we gonna make to much changes it's gonna stuck at first on 500mb, then raise to 600mb-1gb, and return to 500mb(not 300mb), so, i think that there's only chunk splitting plugin issue. |
👆 since doing this, we had no more memory leaks, developing a whole day on a huge project, with steadily running webpack dev server. just to mention again.. Ps. And all that also without the split chunks plugin |
so, you suggest disable chunk splitting on dev server? But that's also not nice for recompile everything everytime. |
No. This is not what I wrote. Should only be a hint to find out the root of the problem. And it seems to be with the source maps library. |
i guess it is the |
Same problem here. webpack version 4.39.2 FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory |
I am also getting this issue:
When adding
This has progressively got worse over the last few days to the point now that I cannot work. |
I close the issue because there are many different problems and it is not possible to track them, many problems have been fixed, if you encounter a problem please create a new issue with a reproducible test repo, thanks |
Отличное решение. Так держать. |
@afwn90cj93201nixr2e1re Нет ничего сложного открыть новую проблему с воспроизводимым примером ошибки/зависания/утечки и тд. Используйте только анлийский язык в будущем. |
Мда, то есть тебе не достаточно этих репортов? 90% которых ссылаются на неверно реализованное кеширование дев сервера... |
@afwn90cj93201nixr2e1re Я настоятельнр рекомендую использовать анлийский для общения. Проблемы с переполнением памяти dev сервера известна при долгой работе и открыта в репозитории dev сервера, нет никакого смысла в дубликате и ее не возможно исправить на стороне webpack. Репортов недостаточно? Половина из них просто спам без какой-либо информации, я не могу починить что-то где-то не зная в чем проблема, извините я не джин или маг. Остальная половина или уже не актулально и устарело, или в сторонних плагинах, который мы тоже не можем исправить. Хочешь быстрого решения - создай хорошо описанную проблему с примером, хочешь еще быстрее - помоги в решении, это открое программное обеспечение. |
So, i think it's better to close this issue with that note, instead |
Here not only bug(s) with webpack-dev-server |
btw most of them (90%) related to cache issue's... |
Do you want to request a feature or report a bug?
bug
What is the current behavior?
The memory increased when running webpack4 in development, and the memory didn't release. So there was memory leak.
Then node will throw error
JavaScript heap out of memory
I saw the heapsnapshot, there was many repeated String Objects which were compiled by webpack.
If the current behavior is a bug, please provide the steps to reproduce.
run webpack development mode with , update the business code and waiting rebuild, then update the code...you will see the increasing memory.
What is the expected behavior?
Clear memory in time.
If this is a feature request, what is motivation or use case for changing the behavior?
Please mention other relevant information such as the browser version, Node.js version, webpack version, and Operating System.
webpack@4.2.0
The text was updated successfully, but these errors were encountered: