|POSIX_MADVISE(3)||Linux Programmer's Manual||POSIX_MADVISE(3)|
int posix_madvise(void *addr, size_t len, int advice);
_POSIX_C_SOURCE >= 200112L
The advice argument is one of the following:
- The application has no special advice regarding its memory usage patterns for the specified address range. This is the default behavior.
- The application expects to access the specified address range sequentially, running from lower addresses to higher addresses. Hence, pages in this region can be aggressively read ahead, and may be freed soon after they are accessed.
- The application expects to access the specified address range randomly. Thus, read ahead may be less useful than normally.
- The application expects to access the specified address range in the near future. Thus, read ahead may be beneficial.
- The application expects that it will not access the specified address range in the near future.
- addr is not a multiple of the system page size or len is negative.
- advice is invalid.
- Addresses in the specified range are partially or completely outside the caller's address space.
In glibc, this function is implemented using madvise(2). However, since glibc 2.6, POSIX_MADV_DONTNEED is treated as a no-op, because the corresponding madvise(2) value, MADV_DONTNEED, has destructive semantics.