pub struct DeallocatedP(_);
A type providing access to the total number of bytes deallocated by the current thread.
The get
method doesn't return the value directly, but actually a pointer to the value. This
allows for very fast repeated lookup, since there is no function call overhead. The pointer type
cannot be sent to other threads, but DeallocatedP::get
can be called on different threads and
will return the appropriate pointer for each of them.
extern crate jemallocator;
extern crate jemalloc_ctl;
use jemalloc_ctl::thread::DeallocatedP;
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
fn main() {
let deallocated = DeallocatedP::new().unwrap();
let deallocated = deallocated.get().unwrap();
let a = deallocated.get();
let buf = vec![0; 1024 * 1024];
let b = deallocated.get();
drop(buf);
let c = deallocated.get();
assert_eq!(a, b);
assert!(b < c);
}
Returns a new Deallocated
.
Returns a thread-local pointer to the total number of bytes deallocated by this thread.
Performs copy-assignment from source
. Read more