开发者

How is dynamic variable bound to address in memory?

开发者 https://www.devze.com 2023-01-09 14:22 出处:网络
I would like to know this: Let\'s assume I let system allocate memory for an array e.g. MyArray. How then computer knows when I use this MyArray variable where to look? How arethese named variables 开

I would like to know this:

Let's assume I let system allocate memory for an array e.g. MyArray. How then computer knows when I use this MyArray variable where to look? How are these named variables 开发者_StackOverflowmanaged at low level?

In short I want to know the relation between defined variable and physical address in memory.

I hope you can understand as this is little cumbersome explanation I couldn't find better words.


In short I want to know the relation between defined variable and physical address in memory.

Your variable=its virtual address.

The virtual to physical address mapping is done by the virtual memory subsystem of your operating system. It is generally uninteresting to know the physical address of your variables.


I assume what you are looking for is how runtime systems do dynamic memory allocation. Depending on the programming language / runtime however, memory can be also allocated on the stack.

There was a similar question that you may have a look at too.


A variable stores the address of the memory so when your program ask for the value in myVar it is actually getting a memory address.

A bit like when you search for a website. You my ask for www.google.com to be displayed but it's actually the ip of google that is used to get the information.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号