how to properly release all memory after use?
alsa-project/alsa-lib issue #93 was edited from xatian:
```C++ int main () { snd_pcm_t* handle; int err; err = ::snd_pcm_open (&handle, "default", SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); ::printf ("snd_pcm_open: %d\n", err); err = ::snd_pcm_close (handle); ::printf ("snd_pcm_close: %d\n", err); ::snd_config_update_free_global (); return 0; } ```
``` ==51583== Memcheck, a memory error detector ==51583== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==51583== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info ==51583== Command: ./alsa-leak ==51583== snd_pcm_open: 0 snd_pcm_close: 0 ==51583== ==51583== HEAP SUMMARY: ==51583== in use at exit: 64,140 bytes in 140 blocks ==51583== total heap usage: 2,937 allocs, 2,797 frees, 635,030 bytes allocated ==51583== ==51583== 4 bytes in 1 blocks are definitely lost in loss record 3 of 71 ==51583== at 0x483AB65: calloc (vg_replace_malloc.c:760) ==51583== by 0x58E0A3E: pa_xmalloc0 (in /usr/lib/x86_64-linux-gnu/libpulse.so.0.21.1) ==51583== by 0x58B5F9E: pa_context_new_with_proplist (in /usr/lib/x86_64-linux-gnu/libpulse.so.0.21.1) ==51583== by 0x4848216: ??? ==51583== by 0x4904ABD: ??? (in /usr/lib/x86_64-linux-gnu/libasound.so.2.0.0) ==51583== by 0x4904F24: ??? (in /usr/lib/x86_64-linux-gnu/libasound.so.2.0.0) ==51583== by 0x4905849: snd_config_searcha_hooks (in /usr/lib/x86_64-linux-gnu/libasound.so.2.0.0) ==51583== by 0x4905940: snd_config_searchva_hooks (in /usr/lib/x86_64-linux-gnu/libasound.so.2.0.0) ==51583== by 0x4905A42: ??? (in /usr/lib/x86_64-linux-gnu/libasound.so.2.0.0) ==51583== by 0x49042D8: snd_config_search_definition (in /usr/lib/x86_64-linux-gnu/libasound.so.2.0.0) ==51583== by 0x4920255: ??? (in /usr/lib/x86_64-linux-gnu/libasound.so.2.0.0) ==51583== by 0x4923227: snd_pcm_open (in /usr/lib/x86_64-linux-gnu/libasound.so.2.0.0) ==51583== ==51583== 4 bytes in 1 blocks are definitely lost in loss record 4 of 71 ==51583== at 0x483AB65: calloc (vg_replace_malloc.c:760) ==51583== by 0x58E0A3E: pa_xmalloc0 (in /usr/lib/x86_64-linux-gnu/libpulse.so.0.21.1) ==51583== by 0x58B5F9E: pa_context_new_with_proplist (in /usr/lib/x86_64-linux-gnu/libpulse.so.0.21.1) ==51583== by 0x5892577: ??? ==51583== by 0x5891F42: ??? ==51583== by 0x491FC84: ??? (in /usr/lib/x86_64-linux-gnu/libasound.so.2.0.0) ==51583== by 0x49202E6: ??? (in /usr/lib/x86_64-linux-gnu/libasound.so.2.0.0) ==51583== by 0x4923227: snd_pcm_open (in /usr/lib/x86_64-linux-gnu/libasound.so.2.0.0) ==51583== by 0x404A5B: main (src/main.cpp:15) ==51583== ==51583== LEAK SUMMARY: ==51583== definitely lost: 8 bytes in 2 blocks ==51583== indirectly lost: 0 bytes in 0 blocks ==51583== possibly lost: 0 bytes in 0 blocks ==51583== still reachable: 64,132 bytes in 138 blocks ==51583== suppressed: 0 bytes in 0 blocks ==51583== Reachable blocks (those to which a pointer was found) are not shown. ==51583== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==51583== ==51583== For lists of detected and suppressed errors, rerun with: -s ==51583== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0) ```
Did I do something wrong? What makes matters worse is that if I duplicate the code more leaks get reported so this is not just some global state that gets left behind. I am using libasound2 1.2.3.2-1 amd64
Thank you!
Issue URL : https://github.com/alsa-project/alsa-lib/issues/93 Repository URL: https://github.com/alsa-project/alsa-lib
participants (1)
-
GitHub issues - edited