The Rust Memory Model – Ownership, References and Manipulation

In the previous chapter, Chapter 2, Sequential Rust Performance and Testing, we discussed factors that contribute or detract from the serial performance of a Rust program. We did not explicitly address concurrent performance for want of sufficient information about the way Rust's abstract memory model interacts with the real memory hierarchy of a machine. In this chapter, we'll discuss Rust's memory model, how to control the layout of types in memory, how types are aliased, and how Rust's memory safety works. We'll dig into the standard library to understand how this plays out in practice. This chapter will also examine common crates in the ecosystem that will be of interest to us later in this book. Please be aware that by the time you read this chapter, the rustc implementation will have changed, potentially making our code listings here no longer square with the naming patterns in rustc itself. If you wish to follow along, please check out Rust at SHA da569fa9ddf8369a9809184d43c600dc06bd4b4d.

By the close of this chapter, we will have:

  • Investigated how Rust lays objects out in memory
  • Discussed the various ways Rust points to memory and their guarantees
  • Discussed how Rust allocates and deallocates memory
  • Discussed how Rust denotes stack and heap allocations 
  • Investigated the internal implementation of Option, Cell, CellRef , Rc and Vec.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.14.93