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

Image

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)

Most upvoted comments

In my case issue is fixed

Please try the following preview release and confirm if it fixes the problem.

 npm i https://pkg.pr.new/biomejs/biome/@biomejs/biome@a6874f9

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.

[!IMPORTANT] If you still face the issue, please share information of how to replicate the issues like detailed steps, dependencies installed and any shell scripts that you run while your editor is open. We might hide your comment if such information isn’t provided, because we are receiving too much noise, and it’s difficult to filter important information to us.

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?

Image

@li-yechao refer to this comment of mine #6784 (comment) to provide more detailed information to us. Preferably, we would like a minimal reproduction

Reproduction steps:

  1. clone https://github.com/AIGNE-io/aigne-framework
  2. pnpm install && pnpm build
  3. open project in vscode
  4. open file package.json in the vscode
  5. CMD + SHIFT + p -> reload window
  6. the biome process will use more and more memory

More information: 7. delte folder tests/browser/dist 8. CMD + SHIFT + p` -> reload window 9. the memory usage just stoped at around 300M

Notice:

  • Here is other dist folder in the workspace, such as packages/cli/dist, but seems like only tests/browser/dist folder cause memory leak
  • And I have tried to set files#include to ["**", "!**/dist/**"], it also not work

https://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:

npm i https://pkg.pr.new/biomejs/biome/@biomejs/biome@6d68074

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):

  "files": {
    "ignoreUnknown": true,
    "includes": ["**", "!**/*.css", "!.next", "!data/test/**", "!node_modules"],
    "experimentalScannerIgnores": [".next", "dist", "node_modules"]
  },

All leaks stopped with experimentalScannerIgnores basically. 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.

Image

@ematipico so far in my local testing on https://pkg.pr.new/biomejs/biome/@biomejs/biome@a6874f9 I can no longer replicate the RAM issue on our codebase.

Oh wait, it seems the check inside the watcher only checks against scanner ignores, not files.includes in general. I was focused on trying to explain what changed in 2.1, but this would’ve been an issue since 2.0, I think.

Is there a specific vscode settings.json or biome.json setting we can use as a workaround?

This seems to be a workaround for me:

{
  "$schema": "https://biomejs.dev/schemas/2.1.1/schema.json",
  "extends": ["ultracite"],
  "files": {
    "includes": [
      "**",
      "!**/node_modules/**",
      "!**/dist/**",
      "!**/.sst/**",
      "!**/.turbo/**",
      "!**/.venv/**",
      "!**/packages/design-system/components/ui/**",
      "!**/packages/design-system/lib/**",
      "!**/packages/design-system/hooks/**",
      "!**/apps/email/.react-email/**"
    ],
    "experimentalScannerIgnores": [
      "node_modules",
      "dist",
      ".sst",
      ".next",
      ".turbo",
      ".venv"
    ]
  }
}

Does anyone have suggestions for good workarounds (other than manually calling the restart biome extension command periodically) for the time being until a fix is in?

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).

Image

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

experimentalScannerIgnores works in my environment (2.1.1). Thanks to @trevorpfiz and @dmythro !

"files": {
  "ignoreUnknown": true,
  "includes": [
    "**",
    "!**/worker-configuration.d.ts",
    "!packages/web/app/components/Icon/Icon.tsx",
    "!**/node_modules/**",
    "!**/public/**",
    "!**/.wrangler/**",
    "!**/dist/**",
    "!**/patches/**",
    "!**/.react-router/**",
    "!**/.turbo/**",
    "!**/out/**",
    "!**/build/**"
  ],
  "experimentalScannerIgnores": [
    "public",
    ".wrangler",
    "node_modules",
    "dist",
    "patches",
    ".react-router",
    ".turbo",
    "out",
    "build"
  ]
},

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.

Image

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:

  "files": {
    "ignore": ["**/*/dist", "**/*/build"],
  },

after upgrade to 2.x and run pnpm exec biome migrate --write, it becomes:

  "files": {
    "includes": ["**", "!**/*/dist", "!**/*/build"],
  },

and if you run npx biome check --verbose, it actually not ignore dist files:

Image

and if I run vite build then vite preview, it bloats my pc

so I manually modified config to:

  "files": {
    "includes": ["**", "!dist", "!build"],
  },

no more dist files:

Image

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.json contains "includes": "**", just like mine did after the migration from 1.x -> 2.x. Perhaps try npx biome lint --verbose to see a list of files that biome processes, I suspect that includes node_modules and dist etc. folders. Or if that command never finishes, try the command from the suggested https://biomejs.dev/guides/investigate-slowness/ to get a tracing.json with 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?

    "includes": [
      "src/**",
      "!src/hooks/**",
      "!src/components/ui/use-toast.ts",
      "!src/components/ui/use-mobile.ts",
      "!src/**/*.generated.d.ts",
      "!src/**/*.gen.ts"
    ]

@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.includes to ["**", "!**/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.ts in 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/biome shows 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 in main would be e6b238063f92bc95d951e3a78dac42408d0814c0, but if that one had solved it, I would expect biome lint to 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!

It seems that the watcher still tries to read folders that are ignored. @jacsamg does that happen with any angular project?

@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

"files": {
    "ignoreUnknown": true,
    "includes": [
      "src/**",
      "!src/modules/shared"
    ]
  }

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.

Oh wait, it seems the check inside the watcher only checks against scanner ignores, not files.includes in general. I was focused on trying to explain what changed in 2.1, but this would’ve been an issue since 2.0, I think.

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.includes isn’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.

If it’s helpful, it seems like the LSP is receiving a new publishDiagnostics notification for every file open in the editor whenever a build is triggered (vite hot reloading in my case).

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.

Image

May be it is somehow related to how biome lsp-proxy works in vscode extension?

@ematipico there is one more reproduction, same config as previous, but with bundler

biome-memory-leak.zip

  1. npm i
  2. npm run build
  3. memory consumption is growing

It happened again, with updated config, where I had excluded manually all directories.

  "files": {
    "includes": [
      "**",
      "!**/node_modules/**",
      "!**/*.css",
      "!**/*.scss",
      "!**/public/**",
      "!**/.wrangler/**",
      "!**/dist/**",
      "!**/icons/**",
      "!**/patches/**"
    ]
  },
Image

May be it somehow not respecting rules or some issue with glob patters.

And now, I’m be able to reproduce this:

  1. Open project in vscode
  2. Wait until everithong starts and initialized
  3. Run build process, it cleans dist directory and outputs new files
  4. biome.exe starts to eat memory

Also It happens if I set empty array

  "files": {
    "includes": []
  },

Also if I set only one directory to check

  "files": {
    "includes": ["./src/**"]
  },

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.

  1. Is the node_modules folder excluded by default?
  2. Will a config like "include": ["src/**/*.js"] search for files only in src?
  3. Will a config like "include": ["**", "!**/*.test.js", "**/special.test.js", "!test"] exclude node_modules from the search?

Those rules also cause same memory leak: lint/correctness/noUndeclaredDependencies lint/correctness/useImportExtensions