I have this test program:
#include <libavformat/avformat.h>
AVFormatContext * formatContext = NULL;
int main( int argc, char* argv[] ) {
if( formatContext ) {
avformat_free_context( formatContext );
formatContext = NULL;
}
return 0;
}
It just does nothing as formatContext pointer is null, it just make sure linker bind with libavformat.
compiled with gcc -o testmem src/main.c -lavformat
And checking with valgrind --tool=memcheck --leak-check=full --leak-resolution=med --track-origins=yes --show-leak-kinds=all ./testmem
Report:
==13956== LEAK SUMMARY:
==13956== definitely lost: 0 bytes in 0 blocks
==13956== indirectly lost: 0 bytes in 0 blocks
==13956== possibly lost: 1,352 bytes in 18 blocks
==13956== still reachable: 48,092 bytes in 233 blocks
==13956== of which reachable via heuristic:
==13956== newarray : 1,536 bytes in 16 blocks
==13956== suppressed: 0 bytes in 0 blocks
==13956==
==13956== For lists of detected and suppressed errors, rerun with: -s
==13956== ERROR SUMMARY: 7 errors from 7 contexts (suppressed: 0 from 0)
I understand it as "libavformat have some uninitialized pointer pointing at nothing".
Is there a missing ffmpeg cleanup function in my test program ?
Is this normal and I shall use a less paranoid set of options with valgrind ?
After following @Paul advice I ended up using this valgrind suppression file.
with
valgrind --tool=memcheck --leak-check=full --leak-resolution=med --track-origins=yes --show-leak-kinds=all --suppressions=testmem.supp ./testmemI guess it's kind of specific to dev env.