miniaudio icon indicating copy to clipboard operation
miniaudio copied to clipboard

memory leaks simple_enumeration valgrind

Open JonathanGirardeau opened this issue 2 years ago • 2 comments

Valgrind says the simple_enumeration binary has memory leaks when using alsa or pulse audio backends. The null backend has no memory leak. ALSA:

valgrind --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all ./a.out

==141836== Memcheck, a memory error detector
==141836== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==141836== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==141836== Command: ./a.out
==141836== 
Playback Devices
    0: 2.1 Surround output to Front and Subwoofer speakers
    1: 4.0 Surround output to Front and Rear speakers
    2: 4.1 Surround output to Front, Rear and Subwoofer speakers
    3: 5.0 Surround output to Front, Center and Rear speakers
    4: 5.1 Surround output to Front, Center, Rear and Subwoofer speakers
    5: 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
    6: Discard all samples (playback) or generate zero samples (capture)
    7: HDA Intel PCH, ALC3204 Analog
    8: HDA Intel PCH, HDMI 1
    9: HDA Intel PCH, HDMI 2
    10: HDA Intel PCH, HDMI 3
    11: HDA Intel PCH, HDMI 1
    12: HDA Intel PCH, HDMI 2
    13: HDA Intel PCH, HDMI 3

Capture Devices
    0: 2.1 Surround output to Front and Subwoofer speakers
    1: 4.0 Surround output to Front and Rear speakers
    2: 4.1 Surround output to Front, Rear and Subwoofer speakers
    3: 5.0 Surround output to Front, Center and Rear speakers
    4: 5.1 Surround output to Front, Center, Rear and Subwoofer speakers
    5: 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
    6: Discard all samples (playback) or generate zero samples (capture)
    7: HDA Intel PCH, ALC3204 Analog
==141836== 
==141836== HEAP SUMMARY:
==141836==     in use at exit: 8 bytes in 1 blocks
==141836==   total heap usage: 38,711 allocs, 38,710 frees, 1,432,191 bytes allocated
==141836== 
==141836== 8 bytes in 1 blocks are still reachable in loss record 1 of 1
==141836==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==141836==    by 0x40142CF: allocate_dtv_entry (dl-tls.c:582)
==141836==    by 0x40142CF: allocate_and_init (dl-tls.c:607)
==141836==    by 0x40142CF: tls_get_addr_tail.isra.0 (dl-tls.c:787)
==141836==    by 0x401ADEB: __tls_get_addr (tls_get_addr.S:55)
==141836==    by 0x4FF3D43: ???
==141836==    by 0x4FF61F2: ???
==141836==    by 0x4FF7526: ???
==141836==    by 0x11495D: ma_context_enumerate_devices__alsa (in /mnt/development/miniaudio/examples/a.out)
==141836==    by 0x12246C: ma_context_get_devices (in /mnt/development/miniaudio/examples/a.out)
==141836==    by 0x1CB4F1: main (in /mnt/development/miniaudio/examples/a.out)
==141836== 
==141836== LEAK SUMMARY:
==141836==    definitely lost: 0 bytes in 0 blocks
==141836==    indirectly lost: 0 bytes in 0 blocks
==141836==      possibly lost: 0 bytes in 0 blocks
==141836==    still reachable: 8 bytes in 1 blocks
==141836==         suppressed: 0 bytes in 0 blocks
==141836== 
==141836== For lists of detected and suppressed errors, rerun with: -s
==141836== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

PULSE AUDIO: pulse_audio.log

JonathanGirardeau avatar Dec 11 '23 12:12 JonathanGirardeau

Thanks. I had a look now and I'm not seeing anything obviously wrong with the miniaudio code. I'm not convinced these are from miniaudio directly - to me they look like they're coming from ALSA and PulseAudio internally.

mackron avatar Dec 13 '23 22:12 mackron

Thank you for checking, I may investigate when I have time.

JonathanGirardeau avatar Dec 20 '23 08:12 JonathanGirardeau