3 ms·
RAII is sorta by definition immediate. They are freed right when they exit scope, this can be annoying for large tree structures. Yeah the GC not being thread
by barchar 13y ago
RAII is sorta by definition immediate. They are freed right when they exit scope, this can be annoying for large tree structures.
Yeah the GC not being thread safe can be annoying. CSP works OK and if you need more performance a thread safe GC may not be fast enough anyway. If rust can pull off ownership tracking between threads in an easy-to-use way then I would be super excited.
- pcwalton 13y agoWell, you don't have to free in your destructor eagerly: you could incrementally release if you wanted to, and still use RAII. But you're right of course that RAII makes it simplest to eagerly deallocate. Eager deallocation is usually what you want anyway, because of its cache effects and because you can just release the memory back to the free list (or the OS) and forget about it. If you repeatedly allocate and deallocate a similarly sized block, for example, eager deallocation means that your block will stay in L1 if it fits.