Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reserve memory on OS X

What's the equivalent to Windows's VirtualAlloc in OS X? That is, how can i reserve a contiguous address space without actually commiting it and then commit chunks of it later?

Thanks,

Alex

like image 840
Alex Avatar asked Jan 21 '23 13:01

Alex


1 Answers

The mmap() function, called with MAP_ANON | MAP_PRIVATE, is very roughly equivalent to VirtualAlloc() with the MEM_RESERVE flag. Memory is then committed by touching each page in the mapping.

like image 50
caf Avatar answered Jan 24 '23 02:01

caf