mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Add back jemalloc support
This commit is contained in:
parent
6764d790ac
commit
9b5fa1c61a
7 changed files with 94 additions and 4 deletions
|
@ -24,7 +24,12 @@ impl std::ops::Sub for MemoryUsage {
|
|||
impl MemoryUsage {
|
||||
pub fn current() -> MemoryUsage {
|
||||
cfg_if! {
|
||||
if #[cfg(all(target_os = "linux", target_env = "gnu"))] {
|
||||
if #[cfg(all(feature = "jemalloc", not(target_env = "msvc")))] {
|
||||
jemalloc_ctl::epoch::advance().unwrap();
|
||||
MemoryUsage {
|
||||
allocated: Bytes(jemalloc_ctl::stats::allocated::read().unwrap() as isize),
|
||||
}
|
||||
} else if #[cfg(all(target_os = "linux", target_env = "gnu"))] {
|
||||
// Note: This is incredibly slow.
|
||||
let alloc = unsafe { libc::mallinfo() }.uordblks as isize;
|
||||
MemoryUsage { allocated: Bytes(alloc) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue