-
-
Notifications
You must be signed in to change notification settings - Fork 633
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
[Bug]: Memory Leak in Dev Server Causing System to Run Out of Application Memory #8976
Comments
I can report the same issue with rspack, I use |
Not sure how to reproduce this amount of memory consumption, but I found there might be something related to memory reseting in mimalloc. I changed memory semantic from |
@h-a-n-a I'm ready to test possible fixes as just running dev server for a while increases memory consumption for me, it wasn't a problem in v1 |
@uladzimirdev Do you mind adding a reproducible demo? Which version of rspack do you use that doesn't have this issue? You may also try @rspack-canary/[email protected] |
This comment has been minimized.
This comment has been minimized.
@uladzimirdev Would you please try again with install-rspack? |
@h-a-n-a I used it to install canary, let me try one more time. yeah, no difference. It looks like it happens mostly when I switch branches without restarting dev server, memory grows with every HMR in action |
Same here. Our application starts out with under 2GB of RAM usage for the rspack-node process, and easily accumulates around 20GB during usage. We are on Are there any plans to investigate / fix this? Thank you for consideration. |
Same for us, when starting rspack the memory usage is ±4GB and growth to around 50GB while developing. |
does it happen after upgrade to 1.2 |
To resolve this issue as soon as possible, please provide as much context as possible:
|
Hello @h-a-n-a I used the reproduce link from @Fausto95, and I have the same issue (even with @rsbuild/core: "^1.1.13") Memory used on start-up ![]() Memory used after some builds (at each save it increases a bit even without any change on the code) ![]() After quitting and restarting the build ![]() Memory used after some builds (Just by spamming ![]() Let me know if you need more context, or you want me to test things. |
My team has seen it grow from 2GB up to 20GB+. It's present on at least 1.1 and 1.2; we have tested on both. It does appear to be HMR-related.
Yeah, it seems to be general edits. Not necessarily changes to imports. The steps are as described:
Are there any logs or dumps I can collect to help? Happy to jump on a call or share configs etc |
Seeing this issue on the latest version (1.2.4). Will start at ~2GB and ramp up to 4-5GB over a few minutes without any file changes or recompilations. Seemingly related: web-infra-dev/rsbuild#4455. I’m unable to increase the memory limit following the instructions in the docs: https://rsbuild.dev/guide/faq/exceptions#javascript-heap-out-of-memory-when-compiling. Appears to have no effect. This, in combination with the ramp up in memory usage means my dev server will crash with
|
downgraded rspack core and rspack cli to 1.0.1 and the issue persists, but not that significant. node process memory usage grew from 3.5Gb to 6.5Gb in an hour. with 1.1.6 it grew from 3Gb to 45Gb |
This might be related to memory cache. I wrote an example. In this example, rspack was invoked rebuild for 4 times. As you can see, when memory cache was ON: ![]() when memory cache was OFF: ![]() This indicates that with memory cache turned on, the more rspack rebuilds, the more memory accumulates. Without memory cache, rspack rebuilds more slowly but also with lower memory retention. You can see every time rebuild was invoked, memory will drop down almost the same as it was when compiler was started. Issue was created: #9405 |
On which version are you using now? I might need to do a bisect to see if anything caused this regression.
I was thinking of clearing the memory cache if they are not necessary anymore. |
v1.1.8 |
@h-a-n-a Reproduce link https://github.com/memory1668/rsbuild-project-vue Memory used on start-up![]() Memory used after some builds![]() |
@memory1668 Try turn off memory cache to see if memory is stable across builds. |
Do you mean this config? In fact, I just tried this configuration, but the memory growth was even faster |
I got the reproduction running on Linux. The result showed the memory consumption is normal without cache enabled. |
Update on the current status of this issue. I've figured out there's some huge memory retention issue if cache was enabled during the build. This is not plaform specific. Here's some data on my ubuntu-22.04 when cache was enabled as a complement to my previous result on macOS using On top of that, we do have some platform specific issue related to macOS according to my investigation and this might be related to mimalloc, which is the memory allocator we used under the hood to speedup our compilation. I also filed an issue over there: microsoft/mimalloc#1025. At the same time, I'm continuously trying to add a minimal reproducible demo to help tackle down the issue as soon as possible. |
Version
Details
While using
rsbuild dev
, I encountered a significant memory leak that caused the system to run out of application memory. This issue makes the system unstable and forces the user to quit applications to free up resources.CodeSandbox: https://codesandbox.io/p/github/Fausto95/react-native-web-rsbuild/main?import=true
Reproduce link
https://github.com/Fausto95/react-native-web-rsbuild
Reproduce Steps
pnpm install
pnpm start:web
/apps/rnw/src/App.js
Activity Monitor
and observe the continuous increase in memory usage for thersbuild-node
processThe text was updated successfully, but these errors were encountered: