Multi-Threaded Video Decoder Leaks Memory

独自空忆成欢 提交于 2019-12-10 12:18:43

问题


My intention is to create a relatively simple video playback system to be used in a larger program that I am working on. Relevant code to the video decoder is here. The best I have been able to do so far is narrow down the memory leak to this section of code (or rather I have not noticed any memory leaks occurring when video is not used).

This is probably a very broad question how ever I am unsure of the scope of the issue I am having and as such of how to word my question.

What I want to know is what have I missed or done wrong that has lead to a noticeable memory leak (by noticeable I mean I can watch memory usage climb megabytes per minute). I have tried ensured that every allocation that I make is matched by a deallocation.

EDIT 1
This is to be built on a Windows 10 machine running MSYS2 (MinGW64)


回答1:


Best way to catch a leak is to use in built memory leak checker on compiler, way better than valgrind if you can compile with it.

Add this line to your makefile:

CXXFLAGS += -fno-omit-frame-pointer -fsanitize=address -ggdb3 -O0

If you use old version of gcc (which doesn't support memory sanitizer/checker use clang).

What I know is av_packet_unref may not work as expected if certain conditions not met (you can read more on inside ffmpeg source codes, can't remember the name it was one of the header files talks about these).

After compilation, let memory climb noticeable, then use Ctrl+C to quit. Memory sanitizer will dump the function/line where memory allocated (and not freed later) automatically. If you can't see source code line numbers, use addr2line tool.

Hope that helps.



来源:https://stackoverflow.com/questions/48047739/multi-threaded-video-decoder-leaks-memory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!