Open shanliu opened 10 months ago
cargo.toml
[package] name = "aaa" version = "0.1.0" edition = "2021" [dependencies] sled = "0.34.6" memory-stats = "1.1.0" humansize = "2.1.3"
use humansize::{format_size, DECIMAL}; fn main() { if let Some(usage) = memory_stats::memory_stats() { println!( "Current physical memory usage: {}", format_size(usage.physical_mem, DECIMAL) ); println!( "Current virtual memory usage: {}", format_size(usage.virtual_mem, DECIMAL) ); } aaaa(); if let Some(usage) = memory_stats::memory_stats() { println!( "Current physical memory usage: {}", format_size(usage.physical_mem, DECIMAL) ); println!( "Current virtual memory usage: {}", format_size(usage.virtual_mem, DECIMAL) ); } } fn aaaa() { let temp_path = "D:/aaa/"; println!("dir:{}", temp_path); // 使用 sled 创建一个数据库 let config = sled::Config::new() .path(temp_path) .cache_capacity(1_000_000) .mode(sled::Mode::LowSpace) .temporary(true); let code_db = config.open().unwrap(); drop(code_db); drop(config); }
output:
Current physical memory usage: 3.87 MB Current virtual memory usage: 851.97 kB dir:D:/aaa/ Current physical memory usage: 27.41 MB Current virtual memory usage: 23.55 MB
Why is the memory not freed when it's already drop db?
cargo.toml
output:
Why is the memory not freed when it's already drop db?