u/bobbytabl3sin r/rust • Recommends
On “Can someone please explain of the memory is allocated here ?”
Not really answering your question but this vid on YouTube helped me a lot understanding memory in Rust: link to this video
11K subscribers • 2 videos on Hallway
Intermediate. Assumes working knowledge.
114K views5 years ago3 recommendations
Programming languagesSystems programmingRustMemory managementData structures
An in-depth explanation of how Rust maps data types, smart pointers, and collections to stack and heap memory.
*UPDATE: This video is re-uploaded with a better audio here youtu.be/7_o-YRxf_cc* Covers how a binary is executed, what segments are mapped to memory, the purpose/working of stack and heap memory, and how values of Rust's data types are laid out in memory. The data types that we cover here are integers, char, Vector, slice, String, string slice, structs, enums, smart pointers like Box, Rc, Arc, Trait object and Fn traits like FnOnce, FnMut and Fn. We also cover the difference between String and str types, Vector and slice types. Topics like fat pointers, optimizations done by the Rust compiler when you wrap a reference inside an Option are also covered. Segments in a binary Stack & Heap CPU Word size Working of stack memory working of Heap memory Integer data types char size_of & align_of Reference Array Vector Slice of T String, str, &str Struct Enum Box pointer Optimizations on Option Copy Vs Move Rc pointer Send vs Sync traits Why RC is neither Send nor Sync Arc Trait object Function pointer Closures Life of an async fn: youtu.be/ZHP9sUqB3Qs stack & heap / virtual address space: lwn.net/Articles/738975/ docs.microsoft.com/en-us/windows-hardware/drivers/gettingsta… Book: Programming Rust by Jason Orendorff, Jim Blandy, and Leonora F.S. TindallWhat people say. Recommended as an excellent resource for understanding how memory is allocated and laid out in Rust.
u/bobbytabl3sin r/rust • Recommends
On “Can someone please explain of the memory is allocated here ?”
u/metaltyphoonin r/rust • Recommends
On “How does enums work? Where are they allocated?”
u/rrklaffedin r/rust • Recommends
On “How do compilers split stack and heap memory?”