rust-lang / rust-lang/rust-analyzer
Huge memory usage with `serde` proc macros
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Problem description
Rust analyzer keeps using more and more memory. It seems to be connected with serdes proc_macros and many fields in the struct.
After the file is opened, during the first minute, memory keeps slowly rising to about 3gb.
At around 2 min mark, it suddenly spikes to 4.3gb.
Around 3-4 mins, it spikes to 7gb.
Around 6-7 mins, it spikes to 12gb.
During all this time, CPU usage is 100% (not all cores, just one).
Started happening a month or 2 ago (I do weekly rust-analyzer updates).
Steps to reproduce
- Fresh install of VSCode on Ubuntu 20.04,
- clone this repo
- open
main.rsand do nothing, just watch CPU/RAM
rust-analyzer version: 0.3.1774-standalone
rustc version: rustc 1.74.1 (a28077b28 2023-12-04)
relevant settings: fresh vs-code install, no custom settings, no ENV variables set
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue using the linked rust-analyzer-serde-huge-memory-usage repository by opening main.rs in VSCode on Ubuntu 20.04, with the reported rust-analyzer and rustc versions. Monitor memory and single-core CPU usage during the first several minutes; done requires addressing the reported growth and spikes, with resource usage no longer escalating under these steps.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100