#Looking for feedback on a diagram I made about memory management in Rust

7 messages · Page 1 of 1 (latest)

clever prawn
#

Hi, I made a draft for a diagram that represents where things are stored in memory for a simple Rust program. The goal is to create a correct representation, not to include every last detail. Is what's being depicted here fundamentally correct or are there any glaring errors? Thanks a lot

uneven plaza
#

My main issues with this are:

  • Most of this stuff depends on the linker (script), so details may vary
  • I think string literals may end up in the text section? or ro_data if you have that.
  • Technically saying "locals" are on the stack isn't really true. Especially in such a small program, they will likely all be in registers.
    Whether you consider these incorrect or not, is up to you
#

Oh, also "heap may be significantly slower than the stack" is a somewhat inaccurate statement. The heap allocations are usually the slow part, after that it's up to cache locality.

#

I'm also pretty sure there was a very similar diagram on this server a while back, but this stuff is hard to find

lost magnet
#

I would also just preface it with this is what virtual memory looks like for that program

uneven plaza
#

#rust-discussions-1 message

#

i guess it's somewhat related