Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Leak on MacOS. Using +7gb Memory on Empty Project #16140

Closed
kyle-tennison opened this issue Dec 18, 2023 · 11 comments
Closed

Memory Leak on MacOS. Using +7gb Memory on Empty Project #16140

kyle-tennison opened this issue Dec 18, 2023 · 11 comments
Labels
A-perf performance issues C-bug Category: bug

Comments

@kyle-tennison
Copy link

image image

When I open the parent dir of any rust project, it looks like there is some sort of memory leak; the "rust-analyzer" icon spins indefinitely as memory racks up.
I'm on macOS Ventura 13.1 on M1 (macbook air 2020). I have no issues whatsoever when I open the crate's directory directly.

I really like this plugin, so I hope this helps. Good luck!

rust-analyzer version: v0.4.1773 (plus whatever the main release is)

rustc version: rustc 1.73.0 (cc66ad468 2023-10-03)

relevant settings: Everything vanilla. No env vars set.

@kyle-tennison kyle-tennison added the C-bug Category: bug label Dec 18, 2023
@kyle-tennison
Copy link
Author

The steps to recreate

  1. mkdir parent_dir
  2. cd parent_dir
  3. mkdir project_dir
  4. cd project_dir
  5. cargo init
  6. code .. (open vscode in parent dir)
  7. open main.rs in vscode
  8. wait a minute for memory to rack up

@Veykril Veykril added A-perf performance issues Broken Window Bugs / technical debt to be addressed immediately labels Dec 18, 2023
@lnicola
Copy link
Member

lnicola commented Dec 18, 2023

Can't reproduce on Linux.

@Veykril
Copy link
Member

Veykril commented Mar 16, 2024

Can't repro this on windows either

@Veykril Veykril closed this as completed Mar 16, 2024
@DrewMcArthur
Copy link

DrewMcArthur commented Mar 24, 2024

@Veykril is this something that got fixed or just was not reproducible? i'm getting around 40gb of memory usage on macOS, with an M2 mbp. 16gb of actual ram, so it's filling up all my swap too. this has been happening pretty consistently working on a specific project, most recently when i changed git branches. I had also changed to the prerelease version, and had the same issue. happy to help try to find the source of this.

Screenshot 2024-03-24 at 12 15 30 PM Screenshot 2024-03-24 at 12 15 58 PM Screenshot 2024-03-24 at 12 16 05 PM Screenshot 2024-03-24 at 12 15 53 PM

Sample of rust-analyzer.txt

edit; i think it has to do with the format-on-save functionality. i save a file, and sometimes it hangs, i get a notification in vs code that it's trying to run the formatter before saving. i have to cancel that to save the file, and then the memory usage quickly balloons. here's a screenshot.
Screenshot 2024-03-24 at 1 24 37 PM

This was referenced Mar 24, 2024
@Veykril
Copy link
Member

Veykril commented Mar 25, 2024

Not reproducible, if you have a leak problem please update to the latest release and check again

@kyle-tennison
Copy link
Author

@Veykril , the example I provided may indeed be reproducible—just not on other OS's. The issue is still present on the latest release, and considering somebody else has bumped into the same issue on MacOS, it might be a mac-specific bug. I appreciate your help though.

@DrewMcArthur , if you're open to it, it would be awesome if you could let us know if the example in the original post will cause a leak for you too; this way, we can verify the issue is reproducible on other mac machines.

@Veykril
Copy link
Member

Veykril commented Mar 25, 2024

Then someone with a mac will have to investigate as I don't have such a machine.

@Veykril Veykril reopened this Mar 25, 2024
@DrewMcArthur
Copy link

i think #16935 fixed my issue but i'll see if i can reproduce

@Hugo4IT
Copy link

Hugo4IT commented Jul 28, 2024

Hello, I have this problem too, my M1 mac has crashed multiple times due to rust-analyzer using up more than 30 gigs of ram and it running out. I am now required to keep task manager open while I use it so that I can kill rust-analyzer when it lags for a while before it crashes my whole system again. I only have this on my macbook, on linux and windows I have not had this issue. I don't want to put any pressure here, it is manageable, but I would love to help diagnose the issue in any way I could. Is there anything I can provide to help? One thing I can say is that I love doing insane stuff with macros and usually the worse my macros get the worse the problem gets, so maybe it has something to do with that?

@Veykril
Copy link
Member

Veykril commented Jul 28, 2024

Can you run the command: rust-analyzer: Memory Usage (Clear Database) the next time you observe a very high memory usage? That will give us some rough stats

@Veykril Veykril changed the title Memory Leak. Using +7gb Memory on Empty Project Memory Leak on MacOS. Using +7gb Memory on Empty Project Jul 28, 2024
@Veykril Veykril removed the Broken Window Bugs / technical debt to be addressed immediately label Sep 30, 2024
@Veykril
Copy link
Member

Veykril commented Feb 7, 2025

Closing as this is too unclear and given the salsa rewrite is coming up, things here might change drastically

@Veykril Veykril closed this as not planned Won't fix, can't repro, duplicate, stale Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-perf performance issues C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

5 participants