jemalloc-ctl

Crates.iojemalloc-ctl
lib.rsjemalloc-ctl
version0.5.4
sourcesrc
created_at2017-10-02 05:46:34.343026
updated_at2023-07-27 16:19:55.414536
descriptionA safe wrapper over jemalloc's control and introspection APIs
homepagehttps://github.com/tikv/jemallocator
repositoryhttps://github.com/tikv/jemallocator
max_upload_size
id34135
size86,481
Jay (BusyJay)

documentation

https://docs.rs/jemalloc-ctl

README

jemalloc-ctl

Travis-CI Status Latest Version docs

A safe wrapper over jemalloc's mallctl*() control and introspection APIs.

Documentation

Platform support

Supported on all platforms supported by the jemallocator crate.

Example


use std::thread;
use std::time::Duration;
use jemalloc_ctl::{stats, epoch};

#[global_allocator]
static ALLOC: jemallocator::Jemalloc = 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));
    }
}

License

This project is licensed under either of

at your option.

Contribution

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.

Commit count: 317

cargo fmt