Skip to content
0:00 / 0:00

#rust#memorylayout#stack

Visualizing memory layout of Rust's data types [See description/first comment]

Sreekanth

11K subscribers • 2 videos on Hallway

YouTube
  • Recommended by 3 people: 3 in engineering communities.

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. Tindall

Why it's here

3 people recommend this

What 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 ?”

Not really answering your question but this vid on YouTube helped me a lot understanding memory in Rust: link to this video

u/metaltyphoonin r/rust • Recommends

On “How does enums work? Where are they allocated?”

Really good video for all types.

u/rrklaffedin r/rust • Recommends

On “How do compilers split stack and heap memory?”

if you can get past the robot voice, this is a pretty good video link to this video