-
Notifications
You must be signed in to change notification settings - Fork 202
Memory leak, Zed editor #3258
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
Comments
Thank you for the report! Finding references is indeed a memory and CPU intensive process because the LSP needs to do a lot of work to find all possible places where something might be used. I'm curious, do you see the memory leak even when not using find references? Or is this specific to that feature? |
@vinistock I don't know. Memory hogging is not instant, it grows over a minute or two. I notice only after the system becomes unresponsive. So I'm not sure which action exactly led to it. Only after the lagging I notice the "Finding references..." hint. It seems it's connected with the memory bloat, it disappears before the memory release. Pls notice I've updated the post, added memory issue with the ruby-lsp-check |
Any update on this ? We use VSCode and dev containers (with Orbstack) and after a while we notice the memory being used by Docker/Orbstack bloats out of control until it disconnects completely and requires a full shutdown and restart of Docker. We didn't used to have this before switching to ruby-lsp as a VSCode extension |
@jwoodrow I solved it by setting excludedPatterns to exclude the problematic files from indexing. Not ideal, but worked. https://shopify.github.io/ruby-lsp/vscode-extension.html#indexing-configuration |
Thanks @ZombieHarvester I'll try and see how to identify the problematic files, any tips on how you proceeded to do this ? |
@jwoodrow There’s a ruby-lsp-check tool for troubleshooting (see https://shopify.github.io/ruby-lsp/troubleshooting.html#indexing). It confirmed the memory leak but didn’t identify the files causing it. I grabbed its source (https://github.com/Shopify/ruby-lsp/blob/main/exe/ruby-lsp-check), added debugging info, and ran it manually, which helped me pinpoint and exclude the problematic files from indexing. Hope it helps! P.S. In my case, the files causing the leak were a large seeds file (thousands of lines with ActiveRecord model calls) and some legacy Ruby 1.8 files stored in a separate folder for reference. |
@ZombieHarvester are you able to share the code patterns used in those files? I'm just wondering if there's some Ruby pattern that causes the indexing to blow up in CPU/memory consumption. If it's just the fact that the file is super long, well indeed processing large files takes more resources and time (and if they aren't relevant in the context of the rest of the codebase, excluding is the way to go). However, if there's some sort of circular reference or structure that degrades performance, we can look into fixing that. |
I'll close this for now. Please let us know if you see it again or if you identify any patterns that slow down the LSP. |
Uh oh!
There was an error while loading. Please reload this page.
Description
I keep getting memory leaks when working on my Rails project in Zed editor on Mac. Ruby consumes 50-80 GB of memory. Nothing suspicious in the Ruby LSP logs. Happens randomly after hours of work, no reproducible steps. The only observation, is that I see stuck "Finding references..." at the moment of memory bloat in the Zed bar. "Restart language server" command helps release the memory.
Ruby LSP log
Zed log
Ruby: 3.3.7
Version manager: asdf
Zed: v0.175.6 (Zed)
OS: macOS 12.7.6
Memory: 16 GiB
Architecture: x86_64
Zed settings:
ruby-lsp-check
also pushes memory. It got to 89 GB before getting killed on 352/2150The text was updated successfully, but these errors were encountered: