malloc returns memory or virtual address space

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

    Malloc allocates on the heap, which is a part of the virtual address space.

    You are not being picky by calling it virtual address space, you are just being too general. It can be compared to saying, "You puke in the bathroom." Strictly speaking that is true but "You puke in the pot" is more precise because the former statement implies that you can puke in the sink or tub too.

    Conceptually, malloc, the heap and virtual memory are supported by most operating systems including Dos and Linux.

提交回复
热议问题