drop_tracer

Crates.iodrop_tracer
lib.rsdrop_tracer
version0.1.1
sourcesrc
created_at2024-02-07 14:53:04.258679
updated_at2024-02-07 16:44:42.203817
descriptionSimple memory leak detector.
homepage
repositoryhttps://github.com/nossie531/drop_tracer
max_upload_size
id1130590
size20,409
(nossie531)

documentation

README

drop_tracer

Simple memory leak detector.

The author of this crate is not good at English.
Forgive me if the document is hard to read.

What is this?

This crate performs simple memory leak detection. This is intended to check local memory leaks in small crates. This is simple to use, just generate items for tracing, embed them in target to be managed, and check later to see if they have been dropped.

(#[global_allocator] attribute is not necessary).

Examples

Example using try_drop (see manual for other options).

let result = DropTracer::try_drop(|t| {
    let x = Chain::new(t.new_item());
    let y = Chain::new(t.new_item());
    x.borrow_mut().link = Some(y.clone());
    y.borrow_mut().link = Some(x.clone());
});

assert_eq!(result.unwrap_err().count(), 2);

struct Chain {
    link: Option<Rc<RefCell<Self>>>,
    _d: DropItem,
}

impl Chain {
    pub fn new(d: DropItem) -> Rc<RefCell<Self>> {
        let result = Self { link: None, _d: d };
        Rc::new(RefCell::new(result))
    }
}

What's new.

v0.1.1

  • DropItem implement Debug trait.
Commit count: 0

cargo fmt