feat: Add mimalloc support, drop hardened_malloc

This commit is contained in:
timedout authored and Jade Ellis committed 2026-11-21 15:21:54 +00:00
1 parent 68068574d3
commit d4ac77a023
8 files changed
+44 -68

No files matched your search

-18
View File
@@ -1,18 +0,0 @@
//! hmalloc allocator
#[global_allocator]
static HMALLOC: hardened_malloc_rs::HardenedMalloc = hardened_malloc_rs::HardenedMalloc;
pub fn trim<I: Into<Option<usize>>>(_: I) -> crate::Result { Ok(()) }
#[must_use]
//TODO: get usage
pub fn memory_usage() -> Option<String> { None }
#[must_use]
pub fn memory_usage_stats() -> Option<[(&'static str, usize); 6]> { None }
#[must_use]
pub fn memory_stats(_opts: &str) -> Option<String> {
Some("Extended statistics are not available from hardened_malloc.".to_owned())
}
+4
View File
@@ -0,0 +1,4 @@
use mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
+7 -20
View File
@@ -1,27 +1,14 @@
//! Integration with allocators
// jemalloc
#[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))]
pub mod default;
#[cfg(feature = "jemalloc")]
pub mod je;
#[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))]
#[cfg(feature = "jemalloc")]
pub use je::{memory_stats, memory_usage, memory_usage_stats, trim};
#[cfg(all(not(target_env = "msvc"), feature = "hardened_malloc", not(feature = "jemalloc")))]
pub mod hardened;
#[cfg(all(
not(target_env = "msvc"),
feature = "hardened_malloc",
not(feature = "jemalloc")
))]
pub use hardened::{memory_stats, memory_usage, memory_usage_stats, trim};
#[cfg(all(feature = "mimalloc", not(feature = "jemalloc")))]
pub mod mimalloc;
#[cfg(any(
target_env = "msvc",
all(not(feature = "hardened_malloc"), not(feature = "jemalloc"))
))]
pub mod default;
#[cfg(any(
target_env = "msvc",
all(not(feature = "hardened_malloc"), not(feature = "jemalloc"))
))]
#[cfg(not(feature = "jemalloc"))]
pub use default::{memory_stats, memory_usage, memory_usage_stats, trim};