Skip to main content

2 docs tagged with "heap"

View all tags

Box<T> for Allocating Data on the Heap

Welcome to a new chapter on some of Rust's most powerful memory management features. We'll begin our exploration of smart pointers with the most straightforward one: Box. A Box is a smart pointer that allows you to store data on the heap instead of the stack. It's a fundamental tool for managing memory and enabling certain data structures in Rust.

The Stack and the Heap

Following our introduction to What is Ownership?, this article dives deeper into a crucial aspect of memory management that underpins the entire ownership system: the Stack and the Heap. Understanding how Rust organizes memory is essential for writing efficient, high-performance code and for truly grasping why ownership works the way it does.