web-infra-dev / rsbuild

The Rspack-based build tool. It's fast, out-of-the-box and extensible.
https://rsbuild.dev/
MIT License
1.81k stars 140 forks source link

[Bug]: HMR Memory leak when saving rsbuild.config.ts multiple times #2288

Open hussain-nz opened 6 months ago

hussain-nz commented 6 months ago

Version

System:
    OS: Windows 10 10.0.19045
    CPU: (16) x64 AMD Ryzen 7 5800H with Radeon Graphics
    Memory: 27.91 GB / 39.39 GB
  Browsers:
    Edge: Chromium (123.0.2420.97)
    Internet Explorer: 11.0.19041.3636
  npmPackages:
    @rsbuild/core: 0.6.13 => 0.6.13
    @rsbuild/plugin-eslint: 0.6.13 => 0.6.13
    @rsbuild/plugin-react: 0.6.13 => 0.6.13
    @rsbuild/plugin-type-check: 0.6.13 => 0.6.13

Details

Running dev server and changing the rsbuild.config.ts causes the memory to jump up 2-4gb at a time, eventually reaching the machine's maximum memory limit and slowing down HMR from 10 seconds to 1+ minutes. Attached a video to show this happening.

Reproduce link

Video attached

Reproduce Steps

  1. rsbuild dev
  2. Change rsbuild.config.ts multiple times
  3. Notice that memory for the rsbuild process is jumping up too much and reaching maximum after 5-10 file changes saved.

https://github.com/web-infra-dev/rsbuild/assets/157121643/bf6c7bad-3b66-4e91-b0f2-d0415a36c6d6

chenjiahan commented 6 months ago

Thanks for the report, we will try to reproduce and fix this.

SoonIter commented 5 months ago

I can't confirm whether this problem is in both mac or win. On my mac, config reload is more obvious than hmr memory.

But there is no jump such as a one-time increase of 2-4GB.

image
TianJianJun0727 commented 3 months ago
image

Rsbuild v0.7.10 仅打开Webstorm运行一个前端项目 开发环境构建失败后再次使用npm工具重新构建,多次之后Node内存占用就10-20GB了,占用内存主要是运行的Rsbuild项目

SoonIter commented 3 months ago

Rsbuild v0.7.10 仅打开Webstorm运行一个前端项目 开发环境构建失败后再次使用npm工具重新构建,多次之后Node内存占用就10-20GB了,占用内存主要是运行的Rsbuild项目

This problem cannot be reproduced in my machine. Can you provide a minimum reproduction? Excluding the impact of webstorm or vscode, you can reproduce it on vscode.

ahqsoftwares commented 3 weeks ago

The same happens on my machine too, windows

ahqsoftwares commented 3 weeks ago

Image

SoonIter commented 2 weeks ago

The same happens on my machine too, windows

hey, can you confirm that this happened after https://github.com/web-infra-dev/rsbuild/pull/3261 (1.0.1-beta.16)?

ahqsoftwares commented 2 weeks ago

The same happens on my machine too, windows

hey, can you confirm that this happened after #3261 (1.0.1-beta.16)?

I am currently at @rsbuild/core 1.0.17

Also, a discovery, removing watchFiles reduces the intensity of the memory leak