My guy be usin' 8GB of memory
rust-analyzer version: Wasn't able to extract (very recent, I'm certain, but unable to determine exactly)
rustc version: rustc 1.68.0-nightly (5ce39f42b 2023-01-20)
relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)
I happened to check on my system resources this morning and happened to notice that out of 32GB, 17 were in use. Interresting, because I have exactly three things open. Lapce, 10 Firefox tabs and system monitor. There's no way that can be right. Turns out Rust Analyzer is using 8GB
It's started by the Lapce editor, which is still quite young, so possible responsible for some memory leaks but nevertheless, 8GB is a bit much IMO. Please let me know what additional information you require in order to address this.
Thanks guys, love ya work <3
Is it hindering you in any way? Does your OS support swap space?
Would be good to identify how this is a problem, 8GB is a lot, but I reckon your system still should be fine with 15GB ram remaining.
Next time it happens, there's a command to show detailed memory usage.
And can you try rust-analyzer analysis-stats --memory-usage . in your project directory?
Lapce uses its own version of rust-analyzer, but you can configure the path in settings. Binaries are available on GitHub Releases if you want to run analysis-stats.
Also, how big is the project you had open (including dependencies)?
Is it hindering you in any way? Does your OS support swap space?
Would be good to identify how this is a problem, 8GB is a lot, but I reckon your system still should be fine with 15GB ram remaining.
Technically / Practically no, but 8GB isn't a healthy amount of memory either.
Next time it happens, there's a command to show detailed memory usage.
And can you try
rust-analyzer analysis-stats --memory-usage .in your project directory?
I did try this, but I wasn't able to determine the PID before Lapce crashed
Also, how big is the project you had open (including dependencies)?
The project is ReLibC. Not a small project by any means, but not gigantic. I've had Lapce/RA handle much larger with substantially less memory.
The project folder is 1.5GB, and cargo.toml lists 17 dependencies of varying size. The most notable is the libc crate
how long were you using that rust-analyzer session, over time the memory usage will increase as we don't free analysis related things. So the more code you touch the more of the analysis will be in memory
how long were you using that rust-analyzer session, over time the memory usage will increase as we don't free analysis related things. So the more code you touch the more of the analysis will be in memory
Not that much actually. 2 days max. I'm working with a total of 6 files, 2 of which are C source
Next time it happens, there's a command to show detailed memory usage.
And can you try
rust-analyzer analysis-stats --memory-usage .in your project directory?
So I just caught RA using 4.4GB. I caught the PID and ran the command you asked. Below is the output:
Failed to create perf counter: Operation not permitted (os error 1)
Failed to create perf counter: Operation not permitted (os error 1)
Database loaded: 1.64s, 80mb (metadata 229.91ms, 287kb; build 1.37s, 108kb)
Failed to create perf counter: Operation not permitted (os error 1)
crates: 10, mods: 183, decls: 3975, fns: 1649
Item Collection: 5.20s, 266mb
Failed to create perf counter: Operation not permitted (os error 1)
exprs: 55937, ??ty: 161 (0%), ?ty: 147 (0%), !ty: 1 r
Inference: 2.80s, 134mb
Total: 8.00s, 401mb
Running under sudo doesn't address the EPERMs
The command I mentioned shows the current usage, but it's probably not available in Lapce (instead, only in Code).
analysis-stats shows the memory usage of a "fresh" RA, so it probably starts low and grows with usage, instead of using 8 GB right away.
The EPERMs are okay, you're probably running it inside a virtual machine.
The command I mentioned shows the current usage, but it's probably not available in Lapce (instead, only in Code).
analysis-stats shows the memory usage of a "fresh" RA, so it probably starts low and grows with usage, instead of using 8 GB right away.
The EPERMs are okay, you're probably running it inside a virtual machine.
Not sure how you got to VM, but that's unfortunately not correct. I'm running this on my machine at home.
Should I try overriding the rust-analyzer with the one from Cargo?
But since the update from a few minutes ago the memusage has been stable at 4.4GB
No, the one in rustup will be older.
If you want, you can try using VS Code for a couple of days, then running that "Show memory usage" command.
No, the one in rustup will be older.
If you want, you can try using VS Code for a couple of days, then running that "Show memory usage" command.
Alright. I'll get back to you in a few days. Thanks for the advice anyway
hi, I come from the above issue ^. rust-analyzer takes gigabytes of ram for me, it makes my system unresponsive and slow at times, I only have 8gb of ram on my computer and it's tedious that I cannot use this computer to use rust on large projects, I never have this problem with large production javascript, swift and python codebases unless I need to multitask other memory hog programs. but in rust, I can't even have a single editor open (whether it be vscode, zed, helix or neovim) even if I have no other application running without it taking up almost all ram space on my computer.
I encountered the same issue. This issue wasn't present in the earlier versions of rust-analyzer this year, so maybe a recent update?
This issue isn't really helpful unfortunately so I'll close it, if r-a "merely" uses a lot of memory after long usage sessions then that is a known problem that is currently not actionable (until we switch to the new salsa). On the other hand if you think r-a is rapidly leaking memory after starting up, please open a separate new issue with more information (and running the "clear database command" which will show some statistics for us to look at, note that will brick the running server instance afterwards so will need a restart).