Is stack memory contiguous physically in Linux?

前端 未结 4 482
遥遥无期
遥遥无期 2020-12-20 18:58

As far as I can see, stack memory is contiguous in virtual memory address, but stack memory is also contiguous physically? And does this have something to do with the stack

4条回答
  •  一向
    一向 (楼主)
    2020-12-20 19:37

    Memory is memory. Stack memory is no faster than heap memory and is no slower. It is all the same. The only thing that makes a memory a stack or a heap is how it is allocated by the application. It is entirely possible to allocate a memory on the heap and make that the program stack.

    The speed difference is in the allocation. Stack memory is allocated by subtracting from the stack pointer: one instruction.

    The process of allocating heap depends upon the heap manager but it is much more complex and may requiring mapping pages to the address space.

提交回复
热议问题