3 ms·
As a complete noob to rust, I found attempting to manage a memory pool that is handed out per request to cause all kinds of borrow checking headaches. My bet i
by codemac 6y ago
As a complete noob to rust, I found attempting to manage a memory pool that is handed out per request to cause all kinds of borrow checking headaches.
My bet is people choose to allocate heavily rather than figure out how to share memory correctly with Rust. I need to learn more rust to get a hang of it so I don't allocate so much.
Are there any rust folks who have a great "list of memory management models for rust"?
- zozbot234 6y agoRust does not yet have local custom allocators ala C++. (You can change the global allocator, but this doesn't help the "memory arena" use case.) The feature is very much on the roadmap, though.
- steveklabnik 6y agoWhile this is true, this doesn't inherently mean you can't do this pattern. https://crates.io/crates/typed_arena https://crates.io/crates/typed_arena for example. It depends on exactly how allocations and your data structure are tied together.
- laurencerowe 6y agoIt would be amazingly handy if someday it was possible to direct Rust to make all heap allocations under a certain block within an arena. At the moment it looks like you have to rewrite any third party code that makes heap allocations to use the arena explicitly at each allocation.
- steveklabnik 6y agoYep, it would. There’s certainly a bunch of work to do here still.