[−][src]Function jemalloc_ctl::raw::name_to_mib
pub fn name_to_mib(name: &[u8], mib: &mut [usize]) -> Result<()>
Translates name
to a mib
(Management Information Base)
mib
s are used to avoid repeated name lookups for applications that
repeatedly query the same portion of jemalloc
s mallctl
namespace.
On success, mib
contains an array of integers. It is possible to pass
mib
with a length smaller than the number of period-separated name
components. This results in a partial MIB that can be used as the basis for
constructing a complete MIB.
For name components that are integers (e.g. the 2
in arenas.bin.2.size
),
the corresponding MIB component will always be that integer. Therefore, it
is legitimate to construct code like the following:
extern crate libc; extern crate jemallocator; extern crate jemalloc_ctl; #[global_allocator] static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; fn main() { use jemalloc_ctl::raw; use libc::{c_uint, c_char}; unsafe { let mut mib = [0; 4]; let nbins: c_uint = raw::read(b"arenas.nbins\0").unwrap(); raw::name_to_mib(b"arenas.bin.0.size\0", &mut mib).unwrap(); for i in 0..4 { mib[2] = i; let bin_size: usize = raw::read_mib(&mut mib).unwrap(); println!("arena bin {} has size {}", i, bin_size); } } }