Do stack and heap memory both refer to the RAM(Assume no paging is being used)?

I am currently taking an operating systems course and I am at a point where we are discussing memory portion of a process. When a program is loaded into memory and thus becomes a process, two forms of memory could be used: either a stack data structure or a heap(I am not quite sure if it's called heap because it actually uses the heap data structure). I have already looked at this link Do the Stack and Heap both exist within your systems RAM? which helped me to a certain extent but did not actually answer my question.

Now my question is:

Stack is the memory where local variables are stored. When a function is called, it is pushed on the stack along with all its variables and when it returns it is popped of the stack. It is kind of a temporary memory. For the heap, there is more control on the memory since once allocated, the memory allocated stays there until explicitly freed. However, are we talking about RAM when we refer to stack and heap? Is the stack and heap of a process A residing in the address space of process A in the RAM?

I know that due to paging that is not always the case because the OS could do efficient memory management and put some memory on the disk while the process is not being used. Let us assume no paging is used just to isolate the two ideas and understand clearer what is happening in memory for a particular process.


Yes they are both in RAM. Perhaps this link from ARM about the microprocessor memory model will help with your understanding?

链接地址: http://www.djcxy.com/p/82736.html

上一篇: 什么存储在堆上,什么存储在堆栈上?

下一篇: 堆栈和堆内存都是指RAM(假设没有使用分页)?