[FFmpeg-devel] [PATCH] ffmpeg.c: Fixed Memory Leak Issue

Chiranjeevi Melam cmelam at rgbnetworks.com
Thu Sep 1 16:00:17 CEST 2011

In do_audio_out(), memory gets allocated for “input_tmp”.

However, there was no free being done on that variable, which was causing a memory leak when ffmpeg would exit (i.e. Valgrind was reporting an error)

By moving input_tmp as a global variable and freeing it in ffmpeg_exit(), then it solves the leak issue.

-----Original Message-----
From: ffmpeg-devel-bounces at ffmpeg.org [mailto:ffmpeg-devel-bounces at ffmpeg.org] On Behalf Of Clément Bœsch
Sent: Wednesday, August 31, 2011 10:42 AM
To: FFmpeg development discussions and patches
Subject: Re: [FFmpeg-devel] [PATCH] ffmpeg.c: Fixed Memory Leak Issue

On Wed, Aug 31, 2011 at 03:05:21PM +0000, Chiranjeevi Melam wrote:
> Hi,


> Fixed Memory Leak issue in ffmpeg.c

How does this happen?

> @@ -931,7 +934,6 @@ need_realloc:
>                          return;
>                     ist->is_start=0;
>                  }else{
> -                    static uint8_t *input_tmp= NULL;
>                      input_tmp= av_realloc(input_tmp, byte_delta + 
> size);

I wonder if using av_fast_malloc wouldn't be more appropriate here, and might fix the issue you're expecting.

Clément B.

More information about the ffmpeg-devel mailing list