How does posix_memalign with alignment size of 4096 bytes differ from mmap
? Does it internally use mmap
or some other mechanism?
posix_memalign
is a higher-level API than mmap
, designed to interoperate with malloc
, free
and realloc
. mmap
usage is more complicated because it offers more functionality than posix_memalign
(mapping files into a process's address space). How it is implemented (in terms of mmap
or otherwise) is left unspecified by the POSIX standard.
Use posix_memalign
where you'd use malloc
if you didn't have alignment restrictions.