This type must not outlive the DBs and caches that are added to it, otherwise the caller will access invalid memory and likely crash. Use PhantomData to ensure it does not outlive its arguments. This is technically a breaking API change, but anything that used this code in this way was likely broken anyway. Co-authored-by: Oleksandr Anyshchenko <aanischenko@gmail.com>
10 lines
265 B
Rust
10 lines
265 B
Rust
use rust_rocksdb::{perf::MemoryUsageBuilder, DB};
|
|
|
|
fn main() {
|
|
let mut builder = MemoryUsageBuilder::new().unwrap();
|
|
{
|
|
let db = DB::open_default("foo").unwrap();
|
|
builder.add_db(&db);
|
|
}
|
|
let _memory_usage = builder.build().unwrap();
|
|
}
|