call decay prior to purge for trim-memory

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2025-01-24 11:29:36 +00:00
parent 5be07ebc0f
commit b5c167de12

View file

@ -141,12 +141,14 @@ pub mod this_thread {
static DEALLOCATED_BYTES: OnceCell<&'static u64> = const { OnceCell::new() };
}
pub fn idle() -> Result { super::notify(&mallctl!("thread.idle")) }
pub fn trim() -> Result { decay().and_then(|()| purge()) }
pub fn trim() -> Result { notify(mallctl!("arena.0.purge")) }
pub fn purge() -> Result { notify(mallctl!("arena.0.purge")) }
pub fn decay() -> Result { notify(mallctl!("arena.0.decay")) }
pub fn idle() -> Result { super::notify(&mallctl!("thread.idle")) }
pub fn flush() -> Result { super::notify(&mallctl!("thread.tcache.flush")) }
pub fn set_muzzy_decay(decay_ms: isize) -> Result<isize> {
@ -239,7 +241,11 @@ pub fn is_prof_enabled() -> Result<bool> {
get::<u8>(&mallctl!("prof.active")).map(is_nonzero!())
}
pub fn trim<I: Into<Option<usize>>>(arena: I) -> Result {
pub fn trim<I: Into<Option<usize>> + Copy>(arena: I) -> Result {
decay(arena).and_then(|()| purge(arena))
}
pub fn purge<I: Into<Option<usize>>>(arena: I) -> Result {
notify_by_arena(arena.into(), mallctl!("arena.4096.purge"))
}