Skip to content
0:00 / 0:00

#memorylayout#pointers#rusttypes

Visualizing memory layout of Rust's data types

Sreekanth

11K subscribers • 2 videos on Hallway

YouTube
  • Recommended by 2 people: 1 on Lobsters and 1 in engineering communities.
  • Presented by Sreekanth

Intermediate. Assumes working knowledge.

65K views3 years ago2 recommendations

Programming languagesSystems programmingRustMemory management

Sreekanth explains how Rust data types, pointers, and collections are laid out in stack and heap memory.

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. Intro 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 - Fn, FnOnce, FnMut 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

2 people recommend this

What people say. Recommended for visualizing and understanding how Rust manages memory and data structures under the hood.

u/Tukang_Tempein r/rust • Recommends

On “Learn rust”

do you mean like this? link to this video

eventhelixon Lobsters • Recommends

Visualizing memory layout of Rust's data types