Skip to main content

dontneed

Function dontneed 

Source
pub(crate) unsafe fn dontneed(ptr: *mut u8, len: usize)
Available on Unix and crate feature pool only.
Expand description

Releases the physical pages of the page-aligned subrange of [ptr, ptr + len), keeping the virtual range mapped.

§Safety

The range must lie within a live mapping exclusively owned by the caller, with no outstanding references into it. After the call the range’s contents are undefined: Linux replaces them with zero pages, but other systems (macOS in particular) may keep the old bytes resident, so callers must fully overwrite the range before reading it again.