[FFmpeg-devel] [PATCH] vaapi_encode: explicitly free buffers after vaEndPicture
wkelleher at gogoair.com
Wed Jun 8 22:02:05 CEST 2016
On 06/08, Mark Thompson wrote:
> 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  that indicates that vaEndPicture might not be
> > freeing the param buffers like the libva documentation says it should.
> > I also noticed that VLC  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
Hmm, good point.
I wonder if this is why libmfx seems to open separate va displays for each encode/decode session.
Unfortunately unless we can solve this, the encoder is pretty useless for any long-running encodes.
Talking to the libva people might help, but any fix that requires modifications to libva/libdrm is
less than ideal because it would require people to likely build those components from source to get
a recent enough version for this to work.
That said... how sure are you about these thread safety concerns? Did you witness any instability
when you tested your vaDestroyBuffer change? I've been running an encode of 12 streams with this
patch for 17+ hours now without any issues. I would have crashed due to OOM by now without this.
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
More information about the ffmpeg-devel