pub fn retain_pages() -> boolExpand description
Keeps the pages of freed buffers mapped so the next request does not fault them again.
Sets the mapping limit to DEFAULT_RETAINED_LIMIT and disables trimming. The effect lasts for
the rest of the process and grows its resident set by the buffers an application allocates and
frees, because those pages stay charged to the process.
Returns true when the heap accepted both settings and false when the platform heap has no
such setting, which is every target outside glibc Linux, so portable code can call it
unconditionally.
let applied = ncnn_rust::heap::retain_pages();
println!("retained pages: {applied}");