Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion uniffi/clash-android-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ reqwest = { version = "0.13", default-features = false, features = ["rustls", "s
tokio-stream = "0.1"
# Memory allocator
tikv-jemallocator = { version = "0.6", optional = true }
jemalloc-ctl = { package = "tikv-jemalloc-ctl", optional = true, version = "0.6.1" }
jemalloc-ctl = { package = "tikv-jemalloc-ctl", optional = true, version = "0.6.1", features = ["stats"] }
rustls-platform-verifier = "0.6.2" # sync with gradle/libs.versions.toml

[dependencies.clash-lib]
Expand Down
7 changes: 4 additions & 3 deletions uniffi/clash-android-ffi/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,16 @@ impl ClashController {
{
use jemalloc_ctl::{epoch, stats};
// Advance the epoch to update statistics
epoch::advance().wrap_err("Failed to advance jemalloc epoch")?;
epoch::advance()
.map_err(|e| eyre::eyre!("Failed to advance jemalloc epoch: {}", e))?;

// Read allocated memory in bytes
let allocated = stats::allocated::read()
.wrap_err("Failed to read allocated memory")?;
.map_err(|e| eyre::eyre!("Failed to read allocated memory: {}", e))?;

// Read resident memory in bytes
let resident = stats::resident::read()
.wrap_err("Failed to read resident memory")?;
.map_err(|e| eyre::eyre!("Failed to read resident memory: {}", e))?;

Ok(MemoryResponse {
inuse: allocated as i64,
Expand Down
Loading