biome: š Memory leak in `biome.exe`
VS Code version
1.202.0
Extension version
3.1.0
Biome version
2.1.0
Operating system
- Windows
- macOS
- Linux
Description
Found performance issues on my PC, randomly checked task manager, and found biome.exe uses 23 GB of memory, and growing little by little. The only solution is to close all vscode instances.
https://github.com/user-attachments/assets/20980467-533c-4b7a-8bef-43782b5807f6
Steps to reproduce
I donāt know, after restart it looks ok, but I donāt know for how long
Expected behavior
To not eat all my memory and to look like
Does this issue occur when using the CLI directly?
No
Link to a minimal reproduction
No response
Logs
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 76
- Comments: 118 (39 by maintainers)
In my case issue is fixed
Please try the following preview release and confirm if it fixes the problem.
Please donāt use this release as a workaround fix, if possible. We discourage the use of preview releases in production because they use a registry that is different from
npmjs.v2.1.2 is out, please test it. Make sure to close the editor and kill any pending
biome- just in case. We will keep the issue open for a little while.also reporting in on macOS, my main biome lsp process is currently at 40gb ram used, Iāve seen it up to 50gb. This is since updating to 2.1.1, seems new after the bump up from 2.0.6?
Reproduction steps:
package.jsonin the vscodeCMD + SHIFT + p-> reload windowMore information: 7. delte folder
tests/browser/dist8. CMD + SHIFT + p` -> reload window 9. the memory usage just stoped at around 300MNotice:
packages/cli/dist, but seems like onlytests/browser/distfolder cause memory leakfiles#includeto["**", "!**/dist/**"], it also not workhttps://github.com/user-attachments/assets/34cc9d37-4027-41ae-933a-6c01f8f13fb4
Please everyone, refrain from adding comments with just screenshots. Use the upvotes feature.
Instead, please try this new preview release and tell us of that helps.
New preview release available for
@biomejs/biome. Install it using the following command:Hope it helps: Iāve been using 2.x (I have 2.1.1 globally and 2.0.6 in projects) for a couple of days with a config like this, and seen no memory leaks so far (I ignore css files because of the Tailwind VSCode extension so far):
All leaks stopped with
experimentalScannerIgnoresbasically. Without it, memory leaks got back eventually (not right away).v2.1.1 you are going to wreck my Macbook SSD with the swapfile. It happened multiple times. This seems to not be a Windows-specific bug.
@ematipico so far in my local testing on
https://pkg.pr.new/biomejs/biome/@biomejs/biome@a6874f9I can no longer replicate the RAM issue on our codebase.This seems to be a workaround for me:
I downgraded to v2.0.6 for now and didnāt have such crazy memory leaks so far (at least for the last 2h of work with
next dev).This happened after updating from
"@biomejs/biome": "2.0.6"to"@biomejs/biome": "2.1.1"so downgrading to
@biomejs/biome": "2.0.6"fixed my problem.Thank you @Profesor08 , I can definitely reproduce the issue! Iāll see what I can do
There is live, how it works
https://github.com/user-attachments/assets/a210f959-7858-4832-b54c-7b97caaef226
It is enought to modify one file in ignored
distdirectoryhttps://github.com/user-attachments/assets/66370212-800c-43c9-a349-bd0f5442d32f
experimentalScannerIgnoresworks in my environment (2.1.1). Thanks to @trevorpfiz and @dmythro !this is my issue too - 64gb ram, linux, vscode extension - biome eventually uses 98% ram during longer sessions before i notice and restart vscode
canāt create a repro right now with my time constraints, but guessing itās reproducible given previous comments - wasnāt an issue until i recently updated to latest cli (or extension?)
when in 1.x, my biome config is:
after upgrade to 2.x and run
pnpm exec biome migrate --write, it becomes:and if you run
npx biome check --verbose, it actually not ignore dist files:and if I run
vite buildthenvite preview, it bloats my pcso I manually modified config to:
no more dist files:
well, now both Disk and Memory usage are normal like before.
so maybe it is the glob?
Just wanted to add that Iām running into this too on MacOS, so itās not Windows specific. Both CPU and Memory usage spiked to a point where the whole machine locked up. Had to do a hard reset.
Rolling back to 2.0.6 makes the issue go away.
@bangonkali Your
biome.jsoncontains"includes": "**", just like mine did after the migration from 1.x -> 2.x. Perhaps trynpx biome lint --verboseto see a list of files that biome processes, I suspect that includesnode_modulesanddistetc. folders. Or if that command never finishes, try the command from the suggested https://biomejs.dev/guides/investigate-slowness/ to get atracing.jsonwith all files that biome tried to load.CPU / mem usage went back to normal for me after I made sure biome only loads my source files.
Perhaps like this?
@arendjr thanks for the explanation, to be fair it was also during a refactor that included turning on import grouping and bulk modifying many files in the IDE, so I may just have gotten spooked. Since then I notice things are fine. You guys can ignore my report
@ematipico Yes, setting
files.includesto["**", "!**/dist/**"]also worked. Unfortunately,["**", "!**/dist"]did not.@jpike88 I also tried your reproduction, and yes, every time I ran the Organize imports on the
gulpfile.tsin that repository, I indeed see the memory usage jump by something between 5 and 10MB. However, as @mikkurogue also noticed, this wasnāt an actual memory leak.While it may appear to be so, the memory did get reclaimed after I tried it a few more times. All in all, I couldnāt get the memory to stay over about 400MB, after which it snapped back to around 200MB. From there it would grow again, until it reached a certain threshold and it would shrink again. I believe what we are looking at here is an artifact of the memory allocator, which avoids doing work over and over for every allocation (that would be horribly slow), and instead it lets the memory grow for a bit, then reclaims it when it grows too much.
In https://github.com/biomejs/biome/issues/6784#issuecomment-3092149172 Iāve attached a folder that I can repro the issue in, there are no hidden files/folders and no build.js artifacts etc⦠itās a clean folder otherwise. I normally run non-bundled stuff using node 24ās experimental type stripping flag anyway.
I have biome 2.1.2 installed in that folderās node_modules, and
~/Library/Application Support/Zed/extensions/work/biomeshows 2.1.2 installed as well as far as the Zed extension is concerned.After testing what you provided in Zed myself on Linux I see the memory spikes a bit after organizing imports but eventually stabilizes and goes back down. In neovim i see it spike harder, but mostly due to it saying that the file does not contain valid UTF-8 formatting so I assume this is an issue on my end.
Have you updated the Zed extension? Iām unsure how Zed rolls out extensions and who is responsible for it so its a shot in the dark
Thanks a ton, @li-yechao ! I was actually able to reproduce the issue with your repository.
Interestingly, I can also resolve it locally by pointing the LSP at a local build from
main. Normally, that would suggest weāve already fixed the issue, but I can actually not fully explain that. The only relevant fix inmainwould be e6b238063f92bc95d951e3a78dac42408d0814c0, but if that one had solved it, I would expectbiome lintto have had the issue too and there should be a diagnostic about a recursive hook now, which is not the case. So I need to dive a little deeper, but Iām really happy with this one!@ematipico Sorry, I didnāt have time to check it that day. Today I decided to do it on a clean project and saw that there was an update. There was no leak with the default Biome configuration.
I updated to ā2.1.2ā in the project where I had the problem (and global) and also reverted to the basic rules; the problem disappeared. Thanks for your work!
biome.json
Well, that is the same here after upgraded to 2.1.1. Using 100% of memory. I have to close the vscode, kill the biome proccess and open vscode again.
I have a MacBook Air M1 and after a vite build also see massive cpu/memory usage that persists until biome is restarted. It seems to affect 2.1.1 but not 2.0.6.
Iāll fix that in https://github.com/biomejs/biome/pull/6839
Yes I found this today as well, but I am using 2.0.6 and the watched files are way too high https://github.com/biomejs/biome/issues/6838
@ematipico I think @jcajuabās comment might actually be an important insight here. Iām not aware what changed between 2.0.6 and 2.1.0 that could have caused this, but if
files.includesisnāt being respected properly anymore in the new version, that could explain most complaints in this thread, because that means that peopleās minified files are likely not getting properly ignored anymore either.Sounds about right and thatās expected š
If I understand correctly, the issue doesnāt happen with the CLI. Only when using the editor, and when working with your project for a while.
With a reproduction shared here, a ignored file was built, and that caused the memory leak
Oh, I was wrong! Biome used 45.7 GB RAM while MacBook was locked! Wow!
Before it also used a lot of CPU so I knew thereās something off because it was warm. Now seems like CPU was not the issue anymore, but RAM still is.
And it definitely is via Biome VSCode extension. Will try previous version for now.
May be it is somehow related to how biome
lsp-proxyworks in vscode extension?@ematipico there is one more reproduction, same config as previous, but with bundler
biome-memory-leak.zip
npm inpm run buildIt happened again, with updated config, where I had excluded manually all directories.
May be it somehow not respecting rules or some issue with glob patters.
And now, Iām be able to reproduce this:
distdirectory and outputs new filesAlso It happens if I set empty array
Also if I set only one directory to check
Sample project with config and dependencies
biome-repro-1752044022371.zip
The scanner scans entire the project even if itās not included in the config, except a few hard-coded denylist. Files in node_modules are also scanned. Behaviour of the scanner changes by turning on any of the āproject rulesā - that requires a detailed module graph created by the scanner. Itās possible that a specific file scanned by the scanner causes memory leak as an edge case.
node_modulesfolder excluded by default?"include": ["src/**/*.js"]search for files only insrc?"include": ["**", "!**/*.test.js", "**/special.test.js", "!test"]excludenode_modulesfrom the search?Those rules also cause same memory leak: lint/correctness/noUndeclaredDependencies lint/correctness/useImportExtensions