zed icon indicating copy to clipboard operation
zed copied to clipboard

Zed memory usage greater than vscode and memory leak issue on long run

Open sheikalthaf opened this issue 1 year ago • 4 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

Zed using more memory than vscode. VSCode - 127MB for big angular project Zed - 220MB for basic HTML and ts file project

I left zed and vscode over the night and in the morning i see that zed memory consumption is more (350MB).

I think there is a memory leak in Zed and also Why it is consuming more memory than VSCode.

Environment

Zed: v0.123.1 (Zed Preview) OS: macOS 14.2.1 Memory: 16 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

Screenshot 2024-02-17 at 9 45 13 AM

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

If you only need the most recent lines, you can run the zed: open log command palette action to see the last 1000.

No response

sheikalthaf avatar Feb 17 '24 04:02 sheikalthaf

I also think there is a memory leak somewhere. When I freshly start a pretty large ts project Zed consumes ~280MB, but sometime after a day of work it's over 4GB.

N8th8n8el avatar Feb 17 '24 08:02 N8th8n8el

Leak could be caused by the same issue as https://github.com/zed-industries/zed/issues/7438 More contribution to the memory bloat might be caused by the way we store LSP logs: they are capped but maybe not enough, see https://github.com/zed-industries/zed/pull/3134 for more context

SomeoneToIgnore avatar Feb 17 '24 09:02 SomeoneToIgnore

https://github.com/typescript-language-server/typescript-language-server/issues/472#issuecomment-1193381252 is also something that makes VSCode consume less memory with tsserver compared to a standalone typescript-language-server

synecdokey avatar Feb 18 '24 17:02 synecdokey

Ive been dealing with the same thing. Im primarily working on a Rust project with a couple files with a few thousand lines of code each. When I open Zed it uses 200-300 MB of memory but after not that long period of time, sometimes as short as an hour or two, it will be anywhere between 4GB too 8GB. I end up killing it and reopening after I get the rainbow wheel of death, and then I go for another couple of hours. I would obviously perfer not to do this but it isnt a deal breaker as I really like the editor. It is something the Zed team should definitly fix and quickly.

AidanRS5772 avatar Mar 05 '24 22:03 AidanRS5772

Maybe some circular reference that is not properly handled with a Weak reference?

mocenigo avatar Mar 16 '24 18:03 mocenigo

I've left some instructions on how to capture memory profiles here: https://github.com/zed-industries/zed/issues/8436#issuecomment-2003220816

If someone wants to take a stab at that, that'd be nice. Otherwise it'd be great to have an example project that we can use to reproduce.

mrnugget avatar Mar 19 '24 11:03 mrnugget