C++ FFmpeg av_寄存器_all()内存泄漏

C++ FFmpeg av_寄存器_all()内存泄漏,c++,memory-leaks,ffmpeg,C++,Memory Leaks,Ffmpeg,我做了一个转换函数,开始找出内存泄漏。我开始做一个小程序来找出泄漏,但出于某种原因,av_register_all()也出现了内存泄漏。有什么东西是我应该免费的吗 main.cpp: #include <math.h> #include <string> #include <queue> #include <deque> #include <iostream> //#ifdef __cplusplus extern "C" {

我做了一个转换函数,开始找出内存泄漏。我开始做一个小程序来找出泄漏,但出于某种原因,av_register_all()也出现了内存泄漏。有什么东西是我应该免费的吗

main.cpp:

#include <math.h>
#include <string>
#include <queue>   
#include <deque>
#include <iostream>

//#ifdef __cplusplus
extern "C" {    
#ifndef __STDC_CONSTANT_MACROS
#define __STDC_CONSTANT_MACROS
#endif
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libswresample/swresample.h>
#include <libswscale/swscale.h>
#include <libavutil/channel_layout.h>
#include <libavutil/common.h>
#include <libavutil/imgutils.h>
#include <libavutil/mathematics.h>
#include <libavutil/avassert.h>
#include <libavutil/avstring.h>
#include <libavutil/frame.h>
#include <libavutil/opt.h>
#include <libavutil/samplefmt.h>
#include <libavutil/timestamp.h>
#include <libavfilter/avfilter.h> 
#include <libavfilter/buffersrc.h> 
#include <libavfilter/buffersink.h> 
#include <libavutil/dict.h>
}


int main (int argc, char ** argv){
    AVFrame *frame;
    AVFrame *filteredFrame;
    AVPacket pkt;

    //Initialize all codecs
    av_register_all();
}

我认为ffmpeg应该在退出时调用,但它没有关闭库的API接口,所以这就是为什么会出现这个问题。您可以就此提交一份申请。

谢谢!请注意,影响相当小,看起来您丢失了81个字节,并且在应用程序中只发生一次。即使这是固定的,它也只会在应用程序退出时释放内存,因此实际影响非常小。不管怎样,谢谢你的bug报告:)这是真的。我最终为valgrind制作了一个抑制文件来抑制它。不过如果能解决这个问题就好了。
==31165== HEAP SUMMARY:
==31165==     in use at exit: 81 bytes in 2 blocks
==31165==   total heap usage: 4 allocs, 2 frees, 167 bytes allocated
==31165== 
==31165== Searching for pointers to 2 not-freed blocks
==31165== Checked 9,196,888 bytes
==31165== 
==31165== 32 bytes in 1 blocks are still reachable in loss record 1 of 2
==31165==    at 0x4C2CC70: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31165==    by 0x6DE768F: _dlerror_run (dlerror.c:141)
==31165==    by 0x6DE70C0: dlopen@@GLIBC_2.2.5 (dlopen.c:87)
==31165==    by 0x8DC7273: x265_api_get_63 (in /usr/local/lib/libx265.so.63)
==31165==    by 0x5958E74: ??? (in /usr/local/lib/libavcodec.so.56.41.100)
==31165==    by 0x59D76B1: avcodec_register_all (in /usr/local/lib/libavcodec.so.56.41.100)
==31165==    by 0x4E6B342: av_register_all (in /usr/local    /lib/libavformat.so.56.36.100)
==31165==    by 0x400830: main (main.cpp:39)
==31165== 
==31165== 49 bytes in 1 blocks are still reachable in loss record 2 of 2
==31165==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==31165==    by 0x400FDC0: _dl_signal_error (dl-error.c:90)
==31165==    by 0x40146CF: _dl_open (dl-open.c:715)
==31165==    by 0x6DE702A: dlopen_doit (dlopen.c:66)
==31165==    by 0x400FFF3: _dl_catch_error (dl-error.c:187)
==31165==    by 0x6DE762C: _dlerror_run (dlerror.c:163)
==31165==    by 0x6DE70C0: dlopen@@GLIBC_2.2.5 (dlopen.c:87)
==31165==    by 0x8DC7273: x265_api_get_63 (in /usr/local/lib/libx265.so.63)
==31165==    by 0x5958E74: ??? (in /usr/local/lib/libavcodec.so.56.41.100)
==31165==    by 0x59D76B1: avcodec_register_all (in /usr/local/lib/libavcodec.so.56.41.100)
==31165==    by 0x4E6B342: av_register_all (in /usr/local/lib/libavformat.so.56.36.100)
==31165==    by 0x400830: main (main.cpp:39)
==31165== 
==31165== LEAK SUMMARY:
==31165==    definitely lost: 0 bytes in 0 blocks
==31165==    indirectly lost: 0 bytes in 0 blocks
==31165==      possibly lost: 0 bytes in 0 blocks
==31165==    still reachable: 81 bytes in 2 blocks
==31165==         suppressed: 0 bytes in 0 blocks
==31165== 
==31165== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
==31165== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)