RustAudio / cpal

Cross-platform audio I/O library in pure Rust
Apache License 2.0
2.66k stars 352 forks source link

Memory leak in WASAPI `input_devices` #802

Open nicolaiunrein opened 11 months ago

nicolaiunrein commented 11 months ago

The below code is causing a memory leak on my machine:

use cpal::traits::HostTrait;

fn main() {
    let host = cpal::ALL_HOSTS
        .into_iter()
        .find(|id| id.name() == "WASAPI")
        .and_then(|id| cpal::host_from_id(*id).ok())
        .expect("No WASAPI host found");

    loop {
        let _ = host.input_devices().unwrap().collect::<Vec<_>>();
        std::thread::sleep(std::time::Duration::from_millis(10));
    }
}

System Info

rustc -Vv output

rustc 1.72.0 (5680fa18f 2023-08-23)
binary: rustc
commit-hash: 5680fa18feaa87f3ff04063800aec256c3d4b4be
commit-date: 2023-08-23
host: x86_64-pc-windows-msvc
release: 1.72.0
LLVM version: 16.0.5
chanderlud commented 3 months ago

I am experiencing the same issue

System Info

rustc -Vv output

rustc 1.78.0 (9b00956e5 2024-04-29)
binary: rustc
commit-hash: 9b00956e56009bab2aa15d7bff10916599e3d6d6
commit-date: 2024-04-29
host: x86_64-pc-windows-msvc
release: 1.78.0
LLVM version: 18.1.2