Memory Leak when using ffmpeg Video Writer (Patch #775)
Description
In function CvVideoWriter_FFMPEG::open()- > icv_add_video_stream_FFMPEG() -> av_new_stream() memory is allocated for stream->info.
When closing the CvVideoWriter this memory should be free'd.
cvcap_ffmpeg:1169
/* free the streams */
for(i = 0; i < oc->nb_streams; i++) {
av_freep(&oc->streams[i]->codec);
+++ av_freep(&oc->streams[i]->info);
av_freep(&oc->streams[i]);
}
I have noticed this bug in version 2.1. In 2.2 it appears in the code, but I have not tested it.
Related issues
related to Bug #3206: VideoWriter.open Leak | Done | 2013-08-08 |
Associated revisions
Merge pull request #775 from bitwangyaoyao:2.4_fixerr
History
Updated by Chav Reddy about 14 years ago
Also:
cvcap_ffmpeg:1185
+++ av_metadata_free(&oc->metadata);
/* free the stream */
av_free(oc);
Replying to chav:
In function CvVideoWriter_FFMPEG::open()- > icv_add_video_stream_FFMPEG() -> av_new_stream() memory is allocated for stream->info.
When closing the CvVideoWriter this memory should be free'd.
cvcap_ffmpeg:1169
/* free the streams */
for(i = 0; i < oc->nb_streams; i++) {
av_freep(&oc->streams[i]->codec);
+++ av_freep(&oc->streams[i]->info);
av_freep(&oc->streams[i]);
}I have noticed this bug in version 2.1. In 2.2 it appears in the code, but I have not tested it.
Updated by Alexander Shishkov about 13 years ago
- Description changed from In function [[CvVideoWriter]]_FFMPEG::open()- > icv_add_video_stream_FFMPE... to In function CvVideoWriter_FFMPEG::open()- > icv_add_video_stream_FFMPEG() ... More
Updated by Alexander Shishkov almost 13 years ago
- Tracker changed from Bug to Patch
- Target version deleted ()
Updated by Alexander Shishkov almost 13 years ago
- Priority changed from Normal to High
Updated by Alexander Reshetnikov almost 13 years ago
Hi, Chav! I noticed it's being used in current trunk version: http://code.opencv.org/projects/opencv/repository/changes/trunk/opencv/modules/highgui/src/cap_ffmpeg_impl.hpp
- Status changed from Open to Cancelled
- Priority changed from High to Normal
- Assignee set to Alexander Reshetnikov
Updated by Alexander Shishkov almost 13 years ago
- Target version set to 2.4.0
Updated by Andrey Kamaev over 12 years ago
- Category changed from highgui-images to highgui-video
Updated by sebastien wybo about 12 years ago
In version 2.43 there still seems to be a 20kB memory leak when deleting a cv::videoWriter using ffmpeg
The proposed patch no longer applies as AV_Stream struct has been changed since
Is a patch underway or is it considered a ffmpeg related bug? or a non important bug?
Updated by Ugo Galassi almost 12 years ago
In opencv there is a memory leak when releasing a video stream. It is still present in 2.4.5
This patch for me worked:
in void CvVideoWriter_FFMPEG::close()
you have to substitute
-----------------------
/* free the streams */
for(i = 0; i < oc->nb_streams; i++)
{
av_freep(&oc->streams[i]->codec);
av_freep(&oc->streams[i]);
}
-----------------------
and
-----------------------
av_free(oc);
-----------------------
with
================
avformat_free_context(oc);
================