malloc returns memory or virtual address space

前端 未结 15 1843
攒了一身酷
攒了一身酷 2021-01-31 06:36

Does malloc allocate a block of memory on the heap or should it be called Virtual Address Space?

Am I being picky calling it Virtual Address Space or this just the legac

15条回答
  •  感情败类
    2021-01-31 07:12

    malloc() allocates the virtual memory, owned by the process.

    During execution the process can be reloaded to the physical memory several times by the operating system. The operating system maps virtual addresses of each process to the physical memory. A process doesn't know the mapping.

    Virtual address space space consist of

    • system space (drivers) and
    • user space (a program code area, a heap for dynamic memory allocation, and a stack for variables, arguments, return values, etc.)

提交回复
热议问题