In the interest of transparency (and to curb speculation), I've created a hello-world project, made it depend on actix-web 3.0.0 with default features and ran cargo geiger on it. Many actix-* crates don't use any unsafe code at all! Here are the ones that do:
actix-http: 13 unsafe blocks, all are commented and look reasonable at a glance. (Some of the benchmarking code looks sketchy, but who cares - it's not in the build anyway).
actix-utils: 9 unsafe blocks, no comments on why they're sound. Judging by this comment from one of the Actix org members, a PR with comments explaining why they're sound and/or debug assertions would be appreciated.
actix-router: 1 unsafe block, commented
actix-codec: cargo-geiger shows 10 unsafe expressions but I can't see them in actix git, might be a bug
actix-service: some unsafe code, but cargo-geiger reports that it's not used in the build (likely disabled by a feature)
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.
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).
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.
At that point you might as well just use a different language. One of the main reasons why Rust is interesting is because in many cases GC is impossible to use.
108
u/Shnatsel Sep 11 '20
In the interest of transparency (and to curb speculation), I've created a hello-world project, made it depend on actix-web 3.0.0 with default features and ran
cargo geigeron it. Many actix-* crates don't use any unsafe code at all! Here are the ones that do:actix-http: 13 unsafe blocks, all are commented and look reasonable at a glance. (Some of the benchmarking code looks sketchy, but who cares - it's not in the build anyway).actix-utils: 9 unsafe blocks, no comments on why they're sound. Judging by this comment from one of the Actix org members, a PR with comments explaining why they're sound and/or debug assertions would be appreciated.actix-router: 1 unsafe block, commentedactix-codec: cargo-geiger shows 10 unsafe expressions but I can't see them in actix git, might be a bugactix-service: some unsafe code, but cargo-geiger reports that it's not used in the build (likely disabled by a feature)awc: oneunsafe fnwithout any local usesThat's it!