Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak alsa::pcm::PCM::open #128

Closed
druskus20 opened this issue Nov 22, 2024 · 0 comments
Closed

Memory leak alsa::pcm::PCM::open #128

druskus20 opened this issue Nov 22, 2024 · 0 comments

Comments

@druskus20
Copy link

I first found out this issue working with cpal. (RustAudio/cpal#928)

I've reproduced this issue with this repo's pcm_record example. (I slightly modified it to make it not infinitely loop).

fn read_loop(pcm: &PCM) -> Result<(), Error> {
    let io = pcm.io_i16()?;
    let mut buf = [0i16; 8192];
    for i in 0..10 {
        // Block while waiting for 8192 samples to be read from the device.
        assert_eq!(io.readi(&mut buf)?, buf.len());
        let r = rms(&buf);
        println!("RMS: {:.1} dB", r);
    }
    Ok(())
}

Running:

 valgrind -s --leak-check=full --show-leak-kinds=all ./target/debug/examples/pcm_record

Shows:

==1331522== 16,616 bytes in 1 blocks are still reachable in loss record 149 of 149
==1331522==    at 0x484D953: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==1331522==    by 0x5159CE8: ??? (in /usr/lib/x86_64-linux-gnu/libpipewire-0.3.so.0.1005.0)
==1331522==    by 0x5174096: ??? (in /usr/lib/x86_64-linux-gnu/libpipewire-0.3.so.0.1005.0)
==1331522==    by 0x515A818: pw_init (in /usr/lib/x86_64-linux-gnu/libpipewire-0.3.so.0.1005.0)
==1331522==    by 0x50BA67B: _snd_pcm_pipewire_open (in /usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_pcm_pipewire.so)
==1331522==    by 0x48CB6CD: ??? (in /usr/lib/x86_64-linux-gnu/libasound.so.2.0.0)
==1331522==    by 0x48CBD6D: ??? (in /usr/lib/x86_64-linux-gnu/libasound.so.2.0.0)
==1331522==    by 0x48FB37E: snd_pcm_open (in /usr/lib/x86_64-linux-gnu/libasound.so.2.0.0)
==1331522==    by 0x122614: alsa::pcm::PCM::open (error.rs:21)
==1331522==    by 0x122510: alsa::pcm::PCM::new (pcm.rs:147)
==1331522==    by 0x120AAC: pcm_record::start_capture (pcm_record.rs:7)
==1331522==    by 0x12181C: pcm_record::main (pcm_record.rs:50)

This is similar to:

jarikomppa/soloud#278

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant