aboutsummaryrefslogtreecommitdiff
path: root/crates/profile/src/memory_usage.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-01-18 18:40:14 +0000
committerGitHub <[email protected]>2021-01-18 18:40:14 +0000
commit08efb8a94360735f505699021eaa901464c76f4a (patch)
tree29704f0e4140261ed68bb5ea3cf52e7385bfc997 /crates/profile/src/memory_usage.rs
parent6764d790ac904533dc7618fd38724a135499f87c (diff)
parent9b5fa1c61a85972da419aa29d61286cb9e268f83 (diff)
Merge #7334
7334: Add back jemalloc support r=jonas-schievink a=jonas-schievink jemalloc is useful due to its introspection API, which allows obtaining quick and accurate memory usage statistics without running into `mallinfo`'s limitations. Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/profile/src/memory_usage.rs')
-rw-r--r--crates/profile/src/memory_usage.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/crates/profile/src/memory_usage.rs b/crates/profile/src/memory_usage.rs
index 83390212a..cb4e54447 100644
--- a/crates/profile/src/memory_usage.rs
+++ b/crates/profile/src/memory_usage.rs
@@ -24,7 +24,12 @@ impl std::ops::Sub for MemoryUsage {
24impl MemoryUsage { 24impl MemoryUsage {
25 pub fn current() -> MemoryUsage { 25 pub fn current() -> MemoryUsage {
26 cfg_if! { 26 cfg_if! {
27 if #[cfg(all(target_os = "linux", target_env = "gnu"))] { 27 if #[cfg(all(feature = "jemalloc", not(target_env = "msvc")))] {
28 jemalloc_ctl::epoch::advance().unwrap();
29 MemoryUsage {
30 allocated: Bytes(jemalloc_ctl::stats::allocated::read().unwrap() as isize),
31 }
32 } else if #[cfg(all(target_os = "linux", target_env = "gnu"))] {
28 // Note: This is incredibly slow. 33 // Note: This is incredibly slow.
29 let alloc = unsafe { libc::mallinfo() }.uordblks as isize; 34 let alloc = unsafe { libc::mallinfo() }.uordblks as isize;
30 MemoryUsage { allocated: Bytes(alloc) } 35 MemoryUsage { allocated: Bytes(alloc) }