Function alloc_track::backtrace_report
source · pub fn backtrace_report() -> BacktraceReportExpand description
Generate a memory usage report for backtraces, if enabled
Examples found in repository?
examples/example.rs (line 26)
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
fn main() {
let (sender, receiver) = mpsc::channel();
std::thread::Builder::new()
.name("thread2".to_string())
.spawn(move || thread(receiver))
.unwrap();
let mut last_print = Instant::now();
loop {
let buf = vec![1u8; 1024];
sender.send(buf).ok();
std::thread::sleep(Duration::from_millis(100));
if last_print.elapsed() > Duration::from_secs(10) {
last_print = Instant::now();
let report = alloc_track::backtrace_report();
println!("BACKTRACES\n{report}");
let report = alloc_track::thread_report();
println!("THREADS\n{report}");
}
}
}