Skip to content

Memory leaks when Rust's async function called from Swift #2758

@b01o

Description

@b01o

Apple's profiling tool Instruments is reporting memory leaks on each async call from Swift to Rust.

I've tried investigating this but couldn't find the cause. Could anyone help take a look?

Minimal example:

// rust side
#[uniffi::export]
async fn rust_side_function() -> u32 { 42 }
// swift side
Task {
    _ = await rustSideFunction()
}

Observed Behavior

Each call to rustSideFunction() leaks 64 + 64 + 128 bytes (256 bytes total) on my machine (M4 Mac).

I've created this repository to demonstrate the example.

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