添加mimalloc,防止axum内存泄露

This commit is contained in:
李运家 2024-06-03 09:41:55 +08:00
parent fb387614d4
commit 0dafebfd59
3 changed files with 27 additions and 1 deletions

20
Cargo.lock generated
View File

@ -303,6 +303,7 @@ version = "0.1.0"
dependencies = [
"api",
"library",
"mimalloc",
"tokio",
]
@ -1053,6 +1054,16 @@ version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
[[package]]
name = "libmimalloc-sys"
version = "0.1.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e7bb23d733dfcc8af652a78b7bf232f0e967710d044732185e561e47c0336b6"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "library"
version = "0.1.0"
@ -1139,6 +1150,15 @@ version = "2.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
[[package]]
name = "mimalloc"
version = "0.1.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9186d86b79b52f4a77af65604b51225e8db1d6ee7e3f41aec1e40829c71a176"
dependencies = [
"libmimalloc-sys",
]
[[package]]
name = "mime"
version = "0.3.17"

View File

@ -12,6 +12,7 @@ members = [".", "api", "domain","library", "service"]
tokio = { workspace = true, features = ["full"]}
api = { path = "api" }
library = { path = "library" }
mimalloc = { workspace = true }
[workspace.dependencies]
tokio = "1.36"
@ -40,4 +41,5 @@ reqwest = "0.12"
futures-executor = "0.3"
error-stack = "0.4"
jsonwebtoken = "9.3.0"
lazy_static = "1.4.0"
lazy_static = "1.4.0"
mimalloc = "0.1.42"

View File

@ -1,4 +1,8 @@
use library::config;
use mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
#[tokio::main]
async fn main() {