release dashmap memory (#1485)

This commit is contained in:
Sijie.Sun
2025-10-18 12:48:04 +08:00
committed by GitHub
parent 8f1786fa23
commit cc8f35787e
29 changed files with 339 additions and 187 deletions
+10
View File
@@ -156,6 +156,16 @@ pub fn get_machine_id() -> uuid::Uuid {
gen_mid
}
pub fn shrink_dashmap<K: Eq + std::hash::Hash, V>(
map: &dashmap::DashMap<K, V>,
threshold: Option<usize>,
) {
let threshold = threshold.unwrap_or(16);
if map.capacity() - map.len() > threshold {
map.shrink_to_fit();
}
}
#[cfg(test)]
mod tests {
use super::*;