opt-in jemalloc
This commit is contained in:
@@ -61,6 +61,7 @@ pub use ra_db::{
|
||||
|
||||
// We use jemalloc mainly to get heap usage statistics, actual performance
|
||||
// differnece is not measures.
|
||||
#[cfg(feature = "jemalloc")]
|
||||
#[global_allocator]
|
||||
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
|
||||
|
||||
|
||||
@@ -133,6 +133,7 @@ struct MemoryStats {
|
||||
}
|
||||
|
||||
impl MemoryStats {
|
||||
#[cfg(feature = "jemalloc")]
|
||||
fn current() -> MemoryStats {
|
||||
jemalloc_ctl::epoch().unwrap();
|
||||
MemoryStats {
|
||||
@@ -140,6 +141,14 @@ impl MemoryStats {
|
||||
resident: Bytes(jemalloc_ctl::stats::resident().unwrap()),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "jemalloc"))]
|
||||
fn current() -> MemoryStats {
|
||||
MemoryStats {
|
||||
allocated: Bytes(0),
|
||||
resident: Bytes(0),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for MemoryStats {
|
||||
|
||||
Reference in New Issue
Block a user