#allocator #jemalloc

tikv-jemalloc-ctl

A safe wrapper over jemalloc’s control and introspection APIs

2 releases

0.4.1 Nov 17, 2020
0.4.0 Jul 21, 2020

#110 in Memory management

Download history 133/week @ 2020-12-30 112/week @ 2021-01-06 123/week @ 2021-01-13 148/week @ 2021-01-20 146/week @ 2021-01-27 130/week @ 2021-02-03 85/week @ 2021-02-10 118/week @ 2021-02-17 171/week @ 2021-02-24 142/week @ 2021-03-03 152/week @ 2021-03-10 164/week @ 2021-03-17 162/week @ 2021-03-24 87/week @ 2021-03-31 145/week @ 2021-04-07 153/week @ 2021-04-14

582 downloads per month
Used in tikv-jemallocator

MIT/Apache

1.5MB
36K SLoC

C 33K SLoC // 0.1% comments Rust 1.5K SLoC // 0.1% comments Visual Studio Project 699 SLoC Shell 234 SLoC // 0.3% comments C++ 213 SLoC // 0.1% comments Python 141 SLoC // 0.4% comments Visual Studio Solution 125 SLoC XSL 9 SLoC

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 tikv-jemallocator crate.

Example


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));
    }
}

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.

Dependencies