This snippet leaks memory, which can be observed by running it in a loop. I think dropping the Runtime should cancel all tasks, which would presumably fix this.
let rt = madsim::runtime::Runtime::new();
let handle = rt.handle();
rt.block_on(async move {
let node = handle.create_node().build();
node.spawn({
let node = node.clone();
async move {
madsim::time::sleep(std::time::Duration::from_secs(1)).await;
drop(node);
}
});
});
This snippet leaks memory, which can be observed by running it in a loop. I think dropping the Runtime should cancel all tasks, which would presumably fix this.