diff --git a/Cargo.lock b/Cargo.lock index 04ad762..cf93e0e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2471,6 +2471,7 @@ dependencies = [ "slint", "slint-build", "thumbhash", + "tikv-jemallocator", "tokio", "tracing", "tracing-subscriber", @@ -5289,6 +5290,26 @@ dependencies = [ "zune-jpeg", ] +[[package]] +name = "tikv-jemalloc-sys" +version = "0.6.1+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd8aa5b2ab86a2cefa406d889139c162cbb230092f7d1d7cbc1716405d852a3b" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "tikv-jemallocator" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0359b4327f954e0567e69fb191cf1436617748813819c94b8cd4a431422d053a" +dependencies = [ + "libc", + "tikv-jemalloc-sys", +] + [[package]] name = "tiny-skia" version = "0.11.4" diff --git a/Cargo.toml b/Cargo.toml index 415af0d..47c684a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ tokio = { version = "1.51.0", features = ["full"] } tracing = "0.1.44" tracing-subscriber = { version = "0.3.23", features = ["env-filter"] } xdg = "3.0.0" +tikv-jemallocator = "0.6" [dependencies.slint] version = "1.16.1" diff --git a/src/main.rs b/src/main.rs index 617bf1d..ca541e7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,6 +16,10 @@ use crate::{ ui::{AppWindow, ImageBucket}, }; +/// Use jemalloc to reduce memory fragmentation. +#[global_allocator] +static ALLOCATOR: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; + mod api; pub mod cachemap; mod thumbhash;