Open yukkit opened 1 year ago
How big is the project you are working on?
How big is the project you are working on?
@bjorn3
How many direct and indirect dependencies do you have? You can count the amount of [[package]]
in Cargo.lock for this.
How many direct and indirect dependencies do you have? You can count the amount of
[[package]]
in Cargo.lock for this.
Based on the size of your project I did expect <3GB of ram usage. Would you mind trying the rust analyzer debug: memory usage command? Note that you will have to restart rust-analyzer after running it as it brings rust-analyzer into an inconsistent state.
Based on the size of your project I did expect <3GB of ram usage. Would you mind trying the rust analyzer debug: memory usage command? Note that you will have to restart rust-analyzer after running it as it brings rust-analyzer into an inconsistent state.
okay, when the memory usage is abnormal, I will execute debug memory usage in the vscode window
Based on the size of your project I did expect <3GB of ram usage.
Do you usually keep it running for days at a time? I also feel like the memory usage is steadily increasing.
Do you usually keep it running for days at a time? I also feel like the memory usage is steadily increasing.
How can I run these commands from vs code? This doesn't seem to be the result I expected
I think the memory reporting doesn't work on some platforms.
I have a similar problem, so I would like to contribute my experience, hoping it helps to diagnose the issue a bit more. I was surprised to see that I had 4.5 GB of memory consumed by rust-analyzer. The worst problem was that I did not even have any Rust project open for a week or more. I have about 10 VS Code projects open, but none are related to Rust. That tells me that rust-analyzer is either keeping track of files that it should not (non-Rust), or it is holding onto files even if the related project is closed in VSCode. The Rust projects open were rustbook tutorials, and I can't imagine them to consume so much memory. I disabled the extension, force quit rust-analyzer, but it still came back with 4.5 GB. Then I closed VS Code, which ensured that rust-analyzer did not start on its own. I hope this gives some idea where to look. I am on Mac M1, Monterey 12.3. VSCode rust-analyzer version is v0.3.1325.
The extension should only start if a Cargo.toml
or *.rs
file is detected. Is there any specific non-rust project for which it starts?
@bjorn3 I found the problematic project, it is https://github.com/aws-samples/serverless-patterns There are many folders in it, and I found 18 Cargo.toml files. I never opened a Rust file there though. I think it is best to enable the extension per project, which I have done already. This solves my problem, but I leave many JS projects open, and I don't run into similar problems. I think an optimization can be done regarding memory usage. 4.5 GB is crazy when I don't have a single Rust file open in VSCode. Few questions come to my mind. Does it run for files that are not Rust? How do you handle monorepo codebases? Maybe rust-analyzer should only be triggered if a Rust file is open in VSCode. Is the only way to work on such a project would be to open only a single Rust folder as a project? I will keep an eye out for this when I work on some Rust stuff.
There's lots of discussion on the topic of lazily loading projects and handling big monorepos in #8631 and #8622. This issue is about memory usage in a single project though.
Thanks @flodiebold , I skimmed it quickly, there are some similar comments. I will check those out.
rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)
v0.4.1297
rustc version: (eg. output of
rustc -V
)rustc 1.64.0 (a55dd71d5 2022-09-19)
relevant settings: (eg. client settings, or environment variables like
CARGO
,RUSTUP_HOME
orCARGO_HOME
)