These are chat archives for rust-lang/rust
.clone()(i.e. increase the reference count) when it is probably required.
mallocand freeing it as soon as objects go out of scope. Its unsafe but suppose I'm careful enough and everything works fine. As far as I understand this approach was considered "slow" and people wrote custom allocators to avoid memory fragmentation and free multiple objects at once
smallveccrate for the stack only allocation?
mallocyou just create something like a new
Box(or anything else that uses heap), and the compiler will insert a
freeinstruction for you for when the owner of that heap allocated value runs out of scope.
Arc) when you do want to use reference counting and don’t want to deal with the borrow checker, but you have to explicitly invoke them, you can write programs and libs that never use ref counts