perf: set static mmap threshold on gnu target env by default
This commit is contained in:
parent
9426a985c6
commit
f59eb77252
5 changed files with 34 additions and 6 deletions
14
src/malloc.rs
Normal file
14
src/malloc.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
use std::os::raw::c_int;
|
||||
|
||||
const M_MMAP_THRESHOLD: c_int = -3;
|
||||
|
||||
extern "C" {
|
||||
fn mallopt(param: c_int, value: c_int) -> c_int;
|
||||
}
|
||||
|
||||
/// Prevents glibc from hoarding memory via memory fragmentation.
|
||||
pub fn limit_mmap_threshold(threshold: i32) {
|
||||
unsafe {
|
||||
mallopt(M_MMAP_THRESHOLD, threshold as c_int);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue