-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix decoder and parser memleaks #32
Conversation
@UstinovAlex could you please check C++ and Python tests with this fix and basic C++ samples? Thanks! |
Fix decoder decode memleak: I attach logs from valgrind:
For reproduce the problem you can use After my fixes:
Thanks! |
Decoder context & decode memleak fixes are OK. |
@UstinovAlex Yes, this variant looks really better. I fixed it. Thanks! |
src/Decoder.cpp
Outdated
return sts; | ||
} | ||
AVFrame* decodedFrame = av_frame_alloc(); | ||
sts = avcodec_receive_frame(decoderContext, decodedFrame); | ||
|
||
if (sts == AVERROR(EAGAIN) || sts == AVERROR_EOF) { | ||
av_frame_free(&decodedFrame); | ||
av_packet_unref(pkt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can move unref from 146, 150 lines to 143 line, just to avoid code duplication
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BykadorovR Fixed
Fixed two potential memory leaks:
Fix free
decoderContext
,AVCodecContext
should be freed withavcodec_free_context()
notavcodec_close()
. Docs aboutavcodec_alloc_context3
.Fix memleak ralated with incorrect memory allocation in
avformat_open_input
func.I attach some logs from valgrind:
After my fixes:
Also attach the code to reproduce the problem:
Thanks!