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_NORMAL
madvise
()
system call.POSIX_MADV_NORMAL
posix_madvise
()
system call.MADV_SEQUENTIAL
madvise
()
system call.POSIX_MADV_SEQUENTIAL
posix_madvise
() system call.MADV_RANDOM
madvise
() system
call.POSIX_MADV_RANDOM
posix_madvise
()
system call.MADV_WILLNEED
madvise
() system call.POSIX_MADV_WILLNEED
posix_madvise
() system call.MADV_DONTNEED
madvise
() system
call.POSIX_MADV_DONTNEED
posix_madvise
() system call.MADV_FREE
madvise
() system call.MADV_ZERO_WIRED_PAGES
madvise
()
system call.MADV_ZERO
madvise
() 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.2 |