How can I know the reason why drop() has not been called in Rust?

Viewed 301
impl Drop for DBWrapper {
fn drop(&mut self) {
    if util::fs::exists(self.path.as_str()) {
        DB::destroy(&DBOptions::new(), self.path.as_str()).expect("destroy failed");
    } 
   
}

I use Drop trait to delete data after no one was using it. Usually it works well. But sometimes historical data has not been deleted.

After logging and checking, I found that the drop() has never been called. So I realized someone must still hold the DBWrapper, but it was hard to find out who is holding it because all the queries of the DBWrapper had already been finished.

So I want know is there any tool for this problem so I can use it to find out who is holding the object? Thanks in advance.

0 Answers
Related