Email or username:

Password:

Forgot your password?
Niklas Korz

Guess #Zed is not the most memory efficient editor after all, despite being written in #RustLang.

On a *completely* unrelated note, did you know that leaking memory in Rust is not considered unsafe?

14 comments
MarkAssPandi

@niklaskorz to be fair, they do mention it in the book sooo
but yeah I caught myself believing that at first too tbh

matze :unarist:

@niklaskorz why should it be considered unsafe? Just because memory is not reclaimed does not lead to undefined behavior.

Christoph Berger

@niklaskorz If "safe" equals "not crashing", then memory leaks *are* safe to a certain point.

That is, no NULL pointer deference, no access to memory after it is freed, no access outside object bounds, etc.

Niklas Korz

@christophberger @matze Semantically speaking I agree, but from a practical point of view, I always feel like there should be some kind of additional "are you sure you want to do this?" for functions like Box::leak.

Also it is probably unrelated to the issues Zed is experiencing, I can imagine the problem lies somewhere in their integration of language servers but also I don't want to dig so I'll just keep to vscode for now.

Christoph Berger

@niklaskorz @matze I guess memory leaks are hard to catch at language level. The compiler cannot tell whether memory that's still referenced continues to be used.

I also moved from Zed back to VSCodium, but for a different reason: I miss several features I'm used to, so I decided to switch back and keep watching Zed's evolution.

Christian ThΓ€ter

@niklaskorz

Leaked memory is technically sound :) just inconvenient. Same goes for deadlocks as well.

In rust there are only few ways one can leak memory. Some cases are explicit (.leak() method). The usual case is having 'std::sync::Arc' (or Rc) forming cycles. I'd do a 'grep Arc src/' to get an idea about where deadlocks happen. But its a big project.

Caleb Maclennan

@niklaskorz True story on both counts. I do wonder if this particular case is not from the Zed editor's own Rust code but from one of the external tools it runs behind the scenes.

(You do know Zed silently downloads and runs 3rd party binaries including an entire nodejs, right?)

Niklas Korz

@alerque This particular case happened while working on nixpkgs. I use the same language server (nixd) on Zed and vscode. The latter does not experience such a massive amount of memory usage.

Mo :ferris: :tux:

@kdwarn @niklaskorz Opening the Rustlings project in Helix only takes 27MiB. Software can be efficient :)

FSMaxB

@niklaskorz Wow, this macOS pop-up is nice. I would like to have something like that on Linux instead of the entire system freezing up for a potentially long amount of time (especially if there is a swap partition) and then randomly killing processes until the system works again.

Niklas Korz

@FSMaxB It does freeze quite a bit, but I somehow managed to take the screenshot inbetween. Also I think macOS has a very generous size limit for swapfile so as long as there's space on disk...

PtiBouchon

@niklaskorz
I do recommend reading faultlore.com/blah/everyone-po about the Leakpocalypse and what was the issue in rust back then to understand a bit more about why it is this way

Moana Rijndael πŸπŸ•

@niklaskorz because it's not. Memory leak cannot cause RCE, or DoS. It's just a performance bug, but not safety issue

Go Up