Crates.io | tikv-jemalloc-ctl |
lib.rs | tikv-jemalloc-ctl |
version | 0.6.0 |
source | src |
created_at | 2020-07-21 11:48:38.891203 |
updated_at | 2024-07-14 15:43:43.289591 |
description | A safe wrapper over jemalloc's control and introspection APIs |
homepage | https://github.com/tikv/jemallocator |
repository | https://github.com/tikv/jemallocator |
max_upload_size | |
id | 267583 |
size | 92,653 |
A safe wrapper over
jemalloc
'smallctl*()
control and introspection APIs.
Supported on all platforms supported by the tikv-jemallocator
crate.
use std::thread;
use std::time::Duration;
use tikv_jemalloc_ctl::{stats, epoch};
#[global_allocator]
static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
fn main() {
// Obtain a MIB for the `epoch`, `stats.allocated`, and
// `atats.resident` keys:
let e = epoch::mib().unwrap();
let allocated = stats::allocated::mib().unwrap();
let resident = stats::resident::mib().unwrap();
loop {
// Many statistics are cached and only updated
// when the epoch is advanced:
e.advance().unwrap();
// Read statistics using MIB key:
let allocated = allocated.read().unwrap();
let resident = resident.read().unwrap();
println!("{} bytes allocated/{} bytes resident", allocated, resident);
thread::sleep(Duration::from_secs(10));
}
}
This project is licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in jemalloc-ctl
by you, as defined in the Apache-2.0 license,
shall be dual licensed as above, without any additional terms or conditions.