I want to measure memory bandwidth using memcpy. I modified the code from this answer:why vectorizing the loop does not have performance improvement which used
The point is that malloc and calloc on most platforms don't allocate memory; they allocate address space.
malloc etc work by:
calloc: the equivalent ofmemset(ptr, 0, size) is issuedFor systems with demand paging (COW) (an MMU could help here), the second options winds downto:
/dev/zeroThis will consume no physical memory, except only for the Page Tables.
/dev/zero. The /dev/zero device is a very special device, in this case mapped to every page of the new memory.