Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible memory leak when use iterator #51

Open
SergeyPalam opened this issue Sep 17, 2024 · 0 comments
Open

Possible memory leak when use iterator #51

SergeyPalam opened this issue Sep 17, 2024 · 0 comments

Comments

@SergeyPalam
Copy link

SergeyPalam commented Sep 17, 2024

I write some code for testing crate:

use memory_stats::memory_stats;
use rusty_leveldb::{DB, LdbIterator, Options};

fn mem_trace(msg: &str){
    if let Some(usage) = memory_stats() {
        println!("Current virtual memory usage in {}: {}", msg, usage.virtual_mem);
    }
}

fn iterate_over_db() {
    let mut opts = Options::default();
    opts.create_if_missing = false;
    let mut db = DB::open("leveldb", opts).unwrap();
    let mut iter = db.new_iter().unwrap();
    while let Some((_, _)) = iter.next() {
    }
}

fn main() {
    mem_trace("Before use LDB");
    iterate_over_db();
    mem_trace("After use LDB");
}

and find that after iterate_over_db() allocated memory hasn't freed. For "leveldb" I use local storage Google Chrome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant