2 ms·
> I don’t think I’ve ever seen it followed by a disclaimer that this only applies to systems with unlimited memory. So, a Turing machine? Why Rust doesn't pr
by Ygg2 3y ago
> I don’t think I’ve ever seen it followed by a disclaimer that this only applies to systems with unlimited memory.
So, a Turing machine?
Why Rust doesn't prevent memory leaks - answer is simple. It's too much pain for modicum of gain.
People crow about lifetime being hard, now imagine how much people would complain if you add another orthogonal system to track memory allocation.
- tialaramex 3y agoYou couldn't meaningfully "prevent memory leaks", and that's what Rust's Leakpocalypse was about. Suppose I have decided to model marriage. My Person type has a spouse: Option<Rc<Person>> and when you marry() another Person it fills out both spouse references. Now I make Bob and Alice, and marry them off, so Alice contains a reference to Bob, while Bob has a reference to Alice. Romantic. Next, I throw away my only Alice reference, but that's OK, I have a Bob, and Bob has a spouse field with a reference to Alice, so Alice isn't destroyed. Then I throw away Bob, likewise Alice has a reference to Bob, so Bob isn't destroyed either. I have now leaked two Persons. I have no way to get them back but they exist forever (well, until program termination).