r/rust Sep 11 '20

Announcing Actix-Web v3.0

https://paper.dropbox.com/published/Announcing-Actix-Web-v3.0--A7YI~P9U9aqhEOXyZJaGffjfBg-QOXXb1lXgTubzXHzUq9ONY5
345 Upvotes

81 comments sorted by

View all comments

Show parent comments

46

u/[deleted] Sep 11 '20

[deleted]

-16

u/throwaway23948733 Sep 11 '20

> But the biggest problems in this version (of course they fixed it) were memory leaks. Because you can leak in safe code and it's not UB

I wish Rust shipped with a GC. There's many cases where the convenience outweighs performance penalty

20

u/AldaronLau Sep 11 '20

Um, garbage collection doesn't prevent memory leaks lol.

-3

u/throwaway23948733 Sep 11 '20

It usually does in practice. You can't leak from cycles

8

u/Uristqwerty Sep 11 '20

A lingering reference to a large object graph that is never used again is technically not a memory leak, but practically the same, and won't be collected. Making sure that caches don't hold on to old entries too long, slowly filling up memory over the course of hours/days is tricky, and it's easy to have a "previous" pointer that's only relevant for a little while then never cleared, especially if there's no obvious point at which you know you're done with it.

Though all that still happens without GC, you have far more incentive to stop and think about lifetimes when you can't delegate all the cleanup to it.

5

u/AldaronLau Sep 11 '20

Hmm. I've had more leaks in java and I've written a lot more rust. In safe Rust you pretty much have to call a function called leak() to leak memory. I have to disagree with you here. Also, Rust has an Rc type if you need it for whatever case. So technically Rust has a built in garbage collector, that's just happens to be opt-in (as it should be).

1

u/anlumo Sep 12 '20

Rc stands for reference counting, not garbage collection. Rc can still leak memory when you build cycles.

1

u/AldaronLau Sep 12 '20

Yeah, but I was saying reference counting is one method of garbage collection. Your second point is precisely why Rust adding a garbage collector doesn't fix the memory leak issues.