Are some allocators lazy?

后端 未结 6 1569
遇见更好的自我
遇见更好的自我 2020-11-27 21:34

I wrote a C program in Linux that mallocs memory, ran it in a loop, and TOP didn\'t show any memory consumption.

then I\'ve done something with that memory, and TOP

6条回答
  •  迷失自我
    2020-11-27 22:08

    On Linux, malloc requests memory with sbrk() or mmap() - either way, your address space is expanded immediately, but Linux does not assign actual pages of physical memory until the first write to the page in question. You can see the address space expansion in the VIRT column, while the actual, physical memory usage in RES.

提交回复
热议问题