mirror of
https://github.com/servo/servo.git
synced 2025-08-02 12:10:29 +01:00
auto merge of #4927 : Ms2ger/servo/mem, r=jdm
This commit is contained in:
commit
52fc01ad37
1 changed files with 18 additions and 10 deletions
|
@ -10,7 +10,6 @@ use std::ffi::CString;
|
|||
use std::old_io::timer::sleep;
|
||||
#[cfg(target_os="linux")]
|
||||
use std::old_io::File;
|
||||
use std::mem;
|
||||
use std::mem::size_of;
|
||||
#[cfg(target_os="linux")]
|
||||
use std::env::page_size;
|
||||
|
@ -213,16 +212,25 @@ fn get_jemalloc_stat(value_name: &str) -> Option<u64> {
|
|||
let value_ptr = &mut value as *mut _ as *mut c_void;
|
||||
let mut value_len = size_of::<size_t>() as size_t;
|
||||
|
||||
let mut rv: c_int;
|
||||
unsafe {
|
||||
// Using the same values for the `old` and `new` parameters is enough
|
||||
// to get the statistics updated.
|
||||
rv = je_mallctl(epoch_c_name.as_ptr(), epoch_ptr, &mut epoch_len, epoch_ptr, epoch_len);
|
||||
if rv == 0 {
|
||||
rv = je_mallctl(value_c_name.as_ptr(), value_ptr, &mut value_len, null_mut(), 0);
|
||||
}
|
||||
// Using the same values for the `old` and `new` parameters is enough
|
||||
// to get the statistics updated.
|
||||
let rv = unsafe {
|
||||
je_mallctl(epoch_c_name.as_ptr(), epoch_ptr, &mut epoch_len, epoch_ptr,
|
||||
epoch_len)
|
||||
};
|
||||
if rv != 0 {
|
||||
return None;
|
||||
}
|
||||
if rv == 0 { Some(value as u64) } else { None }
|
||||
|
||||
let rv = unsafe {
|
||||
je_mallctl(value_c_name.as_ptr(), value_ptr, &mut value_len,
|
||||
null_mut(), 0)
|
||||
};
|
||||
if rv != 0 {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(value as u64)
|
||||
}
|
||||
|
||||
// Like std::macros::try!, but for Option<>.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue