Skip to main content

advise_pageout

Function advise_pageout 

Source
pub fn advise_pageout(bytes: &[u8])
Available on Unix and crate feature pager only.
Expand description

Proactively reclaims (swaps out) the resident pages of bytes via MADV_PAGEOUT, holding RSS at the caller’s budget right now rather than waiting for kernel LRU to reclaim under pressure the way pageout_swap’s MADV_COLD hint does.

Unlike pageout_swap, this takes a borrow and does not transfer ownership: the allocation stays addressable in the caller’s address space, so a later read simply re-faults the swapped-out pages back in. That suits a buffer the caller must keep reachable — e.g. the column pager’s lz4-compressed bytes kept in memory — but still wants evicted eagerly so the budget is real instead of a fiction the kernel only honors at the pressure cliff.

On non-Linux targets this is a no-op (matching MADV_COLD).