Skip to main content

basic/
basic.rs

1use ferroalloc_probe::{start_flush_thread, FerroAllocator};
2
3#[global_allocator]
4static ALLOC: FerroAllocator = FerroAllocator;
5
6fn main() {
7    // Connect to the analyzer before any tracked work begins
8    start_flush_thread(7777);
9
10    println!("Allocating some data...");
11
12    let v: Vec<u8> = vec![0u8; 1024 * 1024]; // 1 MB
13    println!("Allocated {} bytes", v.len());
14
15    let s = String::from("ferroalloc probe example");
16    println!("String: {s}");
17
18    // v and s are dropped here — dealloc events are emitted automatically
19    println!("Done. Check the analyzer for allocation data.");
20}