3 ms·
Use memory arenas and never think about any of this again.
by floor_ 3y ago
Use memory arenas and never think about any of this again.
- spacechild1 3y agoHow do arenas prevent out-of-bound access, double free or stale pointers?
- estebank 3y agoOut of bound access is avoided because you ise handles that the arena has given you, creating an invalid handle is restricted. You avoid double free because of Rust's owbership semantics that make the arena itself reaponsible for "deallocation" (which is just blanking the value and letting Drop do its thing). You avoid stale pointers because every access is checked at runtime if you're using a generational arena.
- spacechild1 3y agoWe are talking about C++ ;-)
- estebank 3y agoYou're right, I was reading a sister thread that was talking about Rust and lost the plot.
- shadowgovt 3y agoSadly, untrue. Source: I use memory arenas, and it's still pretty trivial to copy (instead of reference) an object onto a stack and then try to save a pointer to that object. All you need is to leave out one `&` and the compiler won't tell you anything went wrong: it'll cheerfully let you retain a pointer to a stack-based object that is going to die because explicit lifetime analysis isn't a part of the language spec.