mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-07 02:09:06 +00:00
release dashmap memory (#1485)
This commit is contained in:
@@ -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::*;
|
||||
|
||||
Reference in New Issue
Block a user