| MADVISE(2) | System Calls Manual | MADVISE(2) |
madvise,
posix_madvise — give advice
about use of memory
#include
<sys/mman.h>
int
madvise(void *addr,
size_t len, int advice);
int
posix_madvise(void *addr,
size_t len, int advice);
The
madvise()
system call allows a process that has knowledge of its memory behavior to
describe it to the system. The advice passed in may be used by the system to
alter its virtual memory paging strategy. This advice may improve
application and system performance. The behavior specified in
advice can only be one of the following values:
MADV_NORMALmadvise()
system call.POSIX_MADV_NORMALposix_madvise()
system call.MADV_SEQUENTIALmadvise()
system call.POSIX_MADV_SEQUENTIALposix_madvise() system call.MADV_RANDOMmadvise() system
call.POSIX_MADV_RANDOMposix_madvise()
system call.MADV_WILLNEEDmadvise() system call.POSIX_MADV_WILLNEEDposix_madvise() system call.MADV_DONTNEEDmadvise() system
call.POSIX_MADV_DONTNEEDposix_madvise() system call.MADV_FREEmadvise() system call.MADV_ZERO_WIRED_PAGESmadvise()
system call.MADV_ZEROmadvise() system call.The
posix_madvise()
behaves same as madvise() except that it uses values
with POSIX_ prefix for the advice system call
argument.
Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error.
madvise() fails if one or more of the
following are true:
EINVAL]EINVAL]ENOMEM]EPERM]ENOTSUP]#include
<sys/types.h> #include
<sys/mman.h>
int
madvise(caddr_t
addr, size_t len, int
advice);;
int
posix_madvise(caddr_t
addr, size_t len, int
advice);;
The include file
<sys/types.h> is necessary.
The type of addr has changed.
mincore(2), minherit(2), mprotect(2), msync(2), munmap(2), compat(5)
The madvise function first appeared in
4.4BSD. The posix_madvise function is part of IEEE
1003.1-2001 and was first implemented in Mac OS X 10.2.
| June 9, 1993 | macOS 15.6 |