From ec70edfff8384eb807a702e56763ac5b80fa7fc8 Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Wed, 5 Feb 2025 12:51:18 +0100 Subject: [PATCH] fix: set M_MMAP_THRESHOLD to lower memory usage significantly --- src/main.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main.rs b/src/main.rs index d4cb5bd..3b4257e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,5 +6,11 @@ use tikv_jemallocator::Jemalloc; static GLOBAL: Jemalloc = Jemalloc; fn main() -> Result<(), Box> { + // Prevents glibc from hoarding memory via memory fragmentation. + #[cfg(all(not(feature = "jemalloc"), target_env = "gnu"))] + unsafe { + libc::mallopt(libc::M_MMAP_THRESHOLD, 65536); + } + cosmic_files::main() }