#allocator #jemalloc

jemalloc-ctl

A safe wrapper over jemalloc’s control and introspection APIs

8 releases

Uses old Rust 2015

0.3.3 Jun 16, 2019
0.3.2 Jun 14, 2019
0.2.0 Aug 2, 2018
0.1.4 Jun 21, 2018
0.1.1 Oct 27, 2017

#25 in Memory management

Download history 1601/week @ 2020-07-02 2388/week @ 2020-07-09 2215/week @ 2020-07-16 2156/week @ 2020-07-23 1894/week @ 2020-07-30 2519/week @ 2020-08-06 2450/week @ 2020-08-13 1769/week @ 2020-08-20 2181/week @ 2020-08-27 1815/week @ 2020-09-03 2258/week @ 2020-09-10 2287/week @ 2020-09-17 2257/week @ 2020-09-24 1215/week @ 2020-10-01 2271/week @ 2020-10-08 1959/week @ 2020-10-15

8,832 downloads per month
Used in 51 crates (7 directly)

MIT/Apache

2.5MB
68K SLoC

C 61K SLoC // 0.1% comments Visual Studio Project 2.5K SLoC Rust 1.5K SLoC // 0.1% comments Shell 836 SLoC // 0.2% comments C++ 426 SLoC // 0.1% comments Python 262 SLoC // 0.4% comments Visual Studio Solution 251 SLoC XSL 28 SLoC

jemalloc-ctl

Travis-CI Status Appveyor 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

extern crate jemallocator;
extern crate jemalloc_ctl;

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.

Dependencies