[FFmpeg-devel] [PATCH] vaapi_encode: explicitly free buffers after vaEndPicture

Mark Thompson sw at jkqxz.net
Wed Jun 8 20:43:41 CEST 2016


On 08/06/16 18:23, Will Kelleher wrote:
> Hi all -
> 
> I'm experiencing some significant heap growth when encoding with VAAPI on
> my Ivy Bridge hardware.  Based on what I'm seeing from Massif, it seems like
> the parameter buffers allocated in vaapi_encode_make_param_buffer are leaking.
> 
> I came across this thread [1] that indicates that vaEndPicture might not be
> freeing the param buffers like the libva documentation says it should.
> 
> I also noticed that VLC [2] seems to explicitly call vaDestroyBuffer on the
> param buffers after vaEndPicture.
> 
> When I try that, the leak is gone.

Yes, I wrote essentially the same code on observing the same issue.

Unfortunately, you need a lot more machinery to do this safely - the change makes all buffer operations thread-unsafe (another thread could allocate a buffer with the ID you are about to try to destroy).  That results in needing VADisplay-global locks around pretty much everything to do with buffers (including any time the user makes use of them).

I don't much like the idea of writing all the code to have locking everywhere (including in all user code talking to libavcodec), so I took the cowardly approach of doing nothing and hiding behind the documentation :/

Therefore, dunno.  Maybe we should talk to the libva people about it?

- Mark



More information about the ffmpeg-devel mailing list