diff --git a/Cargo.lock b/Cargo.lock index 46e7d5b4e..6abfe6f97 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -402,6 +402,7 @@ dependencies = [ "electrs-rocksdb", "env_logger", "hex_lit", + "jemallocator", "log", "parking_lot", "prometheus", @@ -590,6 +591,26 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +[[package]] +name = "jemalloc-sys" +version = "0.5.4+5.3.0-patched" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac6c1946e1cea1788cbfde01c993b52a10e2da07f4bac608228d1bed20bfebf2" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "jemallocator" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0de374a9f8e63150e6f5e8a60cc14c668226d7a347d8aee1a45766e3c4dd3bc" +dependencies = [ + "jemalloc-sys", + "libc", +] + [[package]] name = "jobserver" version = "0.1.26" diff --git a/Cargo.toml b/Cargo.toml index 039224589..5c842f53f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,6 +29,7 @@ configure_me = "0.4" crossbeam-channel = "0.5" dirs-next = "2.0" env_logger = "0.10" +jemallocator = "0.5" log = "0.4" parking_lot = "0.12" prometheus = { version = "0.13", optional = true } diff --git a/src/bin/electrs.rs b/src/bin/electrs.rs index f41c88a70..dfa7abdaa 100644 --- a/src/bin/electrs.rs +++ b/src/bin/electrs.rs @@ -1,5 +1,10 @@ use anyhow::Result; +use jemallocator::Jemalloc; + +#[global_allocator] +static GLOBAL: Jemalloc = Jemalloc; + fn main() -> Result<()> { electrs::run() }