Skip to content

Commit

Permalink
fix: use mimalloc on Linux to mitigate "memory leak"
Browse files Browse the repository at this point in the history
  • Loading branch information
XOR-op committed Jul 6, 2024
1 parent b254513 commit 4ae308a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions boltconn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ netlink-sys = "0.8.3"
netlink-packet-core = "0.5.0"
netlink-packet-sock-diag = "0.4.0"
procfs = "0.16.0"
mimalloc = "0.1.43"

[dev-dependencies]
tracing-test = "0.2.4"
8 changes: 8 additions & 0 deletions boltconn/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ mod platform;
mod proxy;
mod transport;

// System default allocator (glibc) won't reclaim freed memory actively on Linux.
// Without enough SWAP and RAM, this may cause OOM. Use MiMalloc to mitigate this issue.
#[cfg(target_os = "linux")]
use mimalloc::MiMalloc;
#[cfg(target_os = "linux")]
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;

#[derive(Debug, Parser)]
#[clap(name = "boltconn", about = "CLI interface of BoltConn", version = env!("CARGO_PKG_VERSION"))]
struct ProgramArgs {
Expand Down

0 comments on commit 4ae308a

Please sign in to comment.