Are some allocators lazy?

后端 未结 6 1572
遇见更好的自我
遇见更好的自我 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:20

    Yes, the memory isn't mapped into your memoryspace unless you touch it. mallocing memory will only setup the paging tables so they know when you get a pagefault in the allocated memory, the memory should be mapped in.

提交回复
热议问题