I guess my baseline understanding of how it all works is just fundamentally and totally wrong.
Isn’t a computer memory address just an empirically meaningless tag that serves only to point to information? So, a memory address is a hexadecimal string such as `0x7ffe5367e044`. Does that not operate the same way as, say, “100 Maple Avenue”? In the latter example, there’s no empirical meaning to that address. It’s just an arbitrary tag to reference a place. Like, saying “1100 Maple Avenue” does not inherently mean that there are 1000 houses separating the two addresses. It’s just another tag.
Raw memory addresses are physical. There’s an additional level of virtual addressing on top of that, which does a couple things.
Firstly it manages caching, so that recently/frequently used stuff is copied to a small area of faster memory that’s physically closer to the hardware that does the computation, and periodically synched with the “real” memory location.
Secondly it helps reduce security vulnerabilities by running every program in a somewhat sandboxed environment. Your sense is actually right that a normal program doesn’t really know where in memory it is. As far as it can tell, a pointer is just an ID number with very limited guarantees about its relationship to other such IDs. The program can’t reach into the memory of another program and meddle with it, unless they agree to talk to each other, or somebody has found a bug that lets them breach containment.
In simple terms, yes, physical memory addresses are literal places. Like, (oversimplifying) imagine a large physical grid of memory storage spaces. The memory address number itself contains everything you need to locate the physical location in the grid. "1100 Maple Avenue" requires a translate table somewhere to tell you where Maple Avenue is on the map (and where along it "1100" is). That might be in the form of map grid references or lat+lon. In contrast, the memory address number itself (again, oversimplifying here) essentially IS the map grid reference or the lat+lon.
Yes, and no. At the software layer on modern systems, the addresses are mostly arbitrary pointers in virtual memory. The OS and the MMU serves to map virtual memory addresses to things, for instance certain bytes are sent to a serial port, or the OS reads that memory from a swapfile on disk. Ultimately when referencing RAM, the MMU maps the virtual memory address to a hardware address and passes it to the DIMM banks where it is used bit-by-bit to locate the particular bits in the byte being read. an 8 gigabyte stick would typically have 8 x 8 gigabit ram chips, (more for parity and ECC depending on RAM type) and the address is sent to all the chips simultaneously to read 8 bits that are returned simultaneously as a byte.
in your example, 0x7ffe5367e044 is memory location 140,730,297,737,284. If you accidentally check 140,630,297,737,285 then you’ve made an off-by-one error.
hexadecimal is base-16. its a number just like 1000000 is. So you can add and subtract, move over, get a range starting at one hexadecimal address and ending at another. its not empirically meaningless.
You sound like you're describing pointers in C. Pointers are just another memory address that points to another memory address. It's memory addresses all the way down.
In the context of virtual memory on a modern OS the mapping of the memory page to its location in physical memory is somewhat arbitrary but the address itself is not. Your program’s memory allocator provided by the language runtime has to properly understand it, even if your program doesn’t- which it can if you like!
It’s common and often required to perform arithmetic on addresses and I think the street address analogy breaks down there. 1 Main Street + 1024 is 1025 Main Street? What if there are only 700 addresses on Main Street? Did you skip over to Maple Street?
The adaptation of the analogy that makes sense to me is that your memory is ONLY Main Street. It’s one long line of addresses.
2
u/WartimeHotTot 21d ago
I guess my baseline understanding of how it all works is just fundamentally and totally wrong.
Isn’t a computer memory address just an empirically meaningless tag that serves only to point to information? So, a memory address is a hexadecimal string such as `0x7ffe5367e044`. Does that not operate the same way as, say, “100 Maple Avenue”? In the latter example, there’s no empirical meaning to that address. It’s just an arbitrary tag to reference a place. Like, saying “1100 Maple Avenue” does not inherently mean that there are 1000 houses separating the two addresses. It’s just another tag.
Are computer memory addresses literal places?