improv: call malloc_trim after view and update calls

This commit is contained in:
Michael Aaron Murphy 2025-02-19 18:13:24 +01:00
parent 76348bb985
commit 1f826e38b9
No known key found for this signature in database
GPG key ID: B2732D4240C9212C
2 changed files with 28 additions and 5 deletions

View file

@ -3,9 +3,17 @@ use std::os::raw::c_int;
const M_MMAP_THRESHOLD: c_int = -3;
extern "C" {
fn malloc_trim(pad: usize);
fn mallopt(param: c_int, value: c_int) -> c_int;
}
pub fn trim(pad: usize) {
unsafe {
malloc_trim(pad);
}
}
/// Prevents glibc from hoarding memory via memory fragmentation.
pub fn limit_mmap_threshold(threshold: i32) {
unsafe {