Skip to content

Memory leak when task contains handle to node it runs on #242

Description

@m-mueller678

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);
        }
    });
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions