aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_prof/src/memory_usage.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-07-22 12:44:05 +0100
committerGitHub <[email protected]>2020-07-22 12:44:05 +0100
commit2dd8ba2b21e3262f25e4245e37549206c8a3bc2d (patch)
tree6dfcadbf3b6a333777f22f54db773118bf1916d4 /crates/ra_prof/src/memory_usage.rs
parent26932e0060b74525f74df5e31ae0c88997e5d667 (diff)
parent9ad41eb9085cd7ceaf479f659a7071df81059b7c (diff)
Merge #5487
5487: Setup global allocator in the correct crate r=matklad a=matklad It worked before, but was roundabout bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_prof/src/memory_usage.rs')
-rw-r--r--crates/ra_prof/src/memory_usage.rs10
1 files changed, 2 insertions, 8 deletions
diff --git a/crates/ra_prof/src/memory_usage.rs b/crates/ra_prof/src/memory_usage.rs
index b1858b06f..ee79ec3ee 100644
--- a/crates/ra_prof/src/memory_usage.rs
+++ b/crates/ra_prof/src/memory_usage.rs
@@ -1,7 +1,7 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2use std::fmt;
2 3
3use cfg_if::cfg_if; 4use cfg_if::cfg_if;
4use std::fmt;
5 5
6pub struct MemoryUsage { 6pub struct MemoryUsage {
7 pub allocated: Bytes, 7 pub allocated: Bytes,
@@ -11,13 +11,7 @@ pub struct MemoryUsage {
11impl MemoryUsage { 11impl MemoryUsage {
12 pub fn current() -> MemoryUsage { 12 pub fn current() -> MemoryUsage {
13 cfg_if! { 13 cfg_if! {
14 if #[cfg(all(feature = "jemalloc", not(target_env = "msvc")))] { 14 if #[cfg(target_os = "linux")] {
15 jemalloc_ctl::epoch::advance().unwrap();
16 MemoryUsage {
17 allocated: Bytes(jemalloc_ctl::stats::allocated::read().unwrap()),
18 resident: Bytes(jemalloc_ctl::stats::resident::read().unwrap()),
19 }
20 } else if #[cfg(target_os = "linux")] {
21 // Note: This is incredibly slow. 15 // Note: This is incredibly slow.
22 let alloc = unsafe { libc::mallinfo() }.uordblks as u32 as usize; 16 let alloc = unsafe { libc::mallinfo() }.uordblks as u32 as usize;
23 MemoryUsage { allocated: Bytes(alloc), resident: Bytes(0) } 17 MemoryUsage { allocated: Bytes(alloc), resident: Bytes(0) }