[XviD-devel] Memory leak using decoder?

Edouard Gomez ed.gomez at free.fr
Wed Dec 1 20:32:20 CET 2004


DT (darktyco at chartermi.net) wrote:
> I am trying to use XviD in my application to decode video, and 
> everything appeared to be working fine until I checked memory usage. The 
> amount of free memory available on the system steadily declines as my 
> program runs. However, if I comment out the line that calls the decoder, 
> this huge memory waste does not occur. I am calling the decoder almost 
> exactly like the API example program does:
> 
>    memset(&xvid_dec_frame, 0, sizeof(xvid_dec_frame_t));
> 
>    xvid_dec_frame.version = XVID_VERSION;
>    decoder_stats->version = XVID_VERSION;
> 
>    xvid_dec_frame.general          = 0;
> 
>    /* Input properties */
>    xvid_dec_frame.bitstream        = buf_ptr;
>    xvid_dec_frame.length           = new_bytes;
> 
>    /* Output properties */
>    xvid_dec_frame.output.plane[0]  = out_buffer;
>    xvid_dec_frame.output.stride[0] = stream_x_dim*2;
>    xvid_dec_frame.output.csp       = XVID_CSP_YUY2;
> 
>    out = xvid_decore(decoder_handle, XVID_DEC_DECODE, &xvid_dec_frame, 
> decoder_stats);
> 
>    return out;
> 
> Is there something wrong with how I am calling the decoder? Should I be 
> freeing some buffer the decoder creates each frame?

No xvid buffers are allocated only once at decoder startup, or
when decoder first encounters a VOL header (a mpeg4 header
which carries the width/height information)

> Or is there a known 
> memory leak in XviD when using YUY2 or something?

xvidcore hans't any memory leak (at least none that
eyeballs can see nor memory checking programs can detect)

But as i can see, you're using thunderbird on X11, so with some
luck you're even probably using a Linux based OS.

If that's the case then i advise you using "valgrind" on your
program. For better reports, compile everything with debug
infos, and statically link against xvidcore. Then run it
through valgrind, and it should tell you how much is leaked.

> As I said before, 
> commenting out the xvid_decore call causes the problem to go away. 
> Sorry, I'm pretty new to using video decoders myself like this. I would 
> really appreciate any advice that could help me figure this out!

Maybe you don't free the decoder instance once you're done
with your stream ?

-- 
Edouard Gomez


More information about the XviD-devel mailing list