malloc returns memory or virtual address space

前端 未结 15 1835
攒了一身酷
攒了一身酷 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:28

    The answer depends on the underlying OS, libc implementation, and hardware architecture. With most modern OS'es (like Linux or Windows) running on the x86 architecture you will get a pointer within the linear address space, but generally this is implementation dependent. I doubt that when, for example, programming some small device (like a microcontroller) in C, malloc() would return a pointer to virtual memory, because there is no virtual memory as such.

提交回复
热议问题