I'm on Macintosh, or Win32.
I say:
void *x = malloc(1024*1024*4);
Or perhaps I say:
void *x = malloc(1024*1024*1024);
That's ordinary malloc. Just pointed clang or MSVC at a .c file and said go.
Do you expect that these calls allocate from heap, or do you expect they allocate from virtual memory?
Do you expect the answer to differ between Macintosh and Windows? Differ between Windows 7 and Windows 11? Differ between the first and second code snippet?
@mcc Just to counter some of the bad answers you're getting: heap and VM allocation *are* very different, because an allocation large enough to cross the threshold to directly using mmap (or platform equivalent) may have a virtual address chosen to use TLBs more efficiently (e.g large pages). It might not even participate in the usual heap structs, and instead the address range or top bits to flag that it's a mapping. It will also very likely return a large-page-aligned address.