#jemalloc #allocator #control-api #api-bindings

no-std tikv-jemalloc-ctl

A safe wrapper over jemalloc's control and introspection APIs

6 releases

0.6.0 Jul 14, 2024
0.5.4 Jul 27, 2023
0.5.0 May 24, 2022
0.4.2 Aug 9, 2021
0.4.0 Jul 21, 2020

#284 in Memory management

Download history 149606/week @ 2024-07-27 149521/week @ 2024-08-03 183435/week @ 2024-08-10 179176/week @ 2024-08-17 181801/week @ 2024-08-24 176637/week @ 2024-08-31 201129/week @ 2024-09-07 173534/week @ 2024-09-14 209305/week @ 2024-09-21 196294/week @ 2024-09-28 241092/week @ 2024-10-05 217141/week @ 2024-10-12 247573/week @ 2024-10-19 242154/week @ 2024-10-26 245719/week @ 2024-11-02 238951/week @ 2024-11-09

1,012,509 downloads per month
Used in 81 crates (16 directly)

MIT/Apache

2MB
52K SLoC

C 47K SLoC // 0.1% comments Rust 2K SLoC // 0.0% comments Visual Studio Project 1.5K SLoC M4 658 SLoC // 0.1% comments Shell 380 SLoC // 0.3% comments C++ 371 SLoC // 0.1% comments Python 261 SLoC // 0.3% 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