[waffle] [PATCH 0/3] Memory leak fixes

Chad Versace chad.versace at intel.com
Tue Jul 1 15:20:05 PDT 2014


On Thu, Jun 26, 2014 at 01:17:30PM +0100, Emil Velikov wrote:
> On 06/06/14 07:38, Chad Versace wrote:
> > On Sun, Jun 01, 2014 at 03:11:59PM +0100, Emil Velikov wrote:
> >> Spotted while searching for a severe memory corruption under wgl.
> >> Did not manage to find it yet, although notices these bad boys.
> > 
> > Awesome. Patch 1 is rb'd and committed to master.
> >>
> >> I will case the corruption bug over the next few days + cleanup&split
> >> the patches hopefully I will see what's going wrong, or perhaps
> >> someone will be kind enough to point out what I'm doing wrong :)
> >>
> >> AFAICS the user is supposed to explicitly release the current context
> >> using waffle_make_current(dry, NULL, NULL), is that correct ?
> > 
> > I'll get back to you on that question tomorrow. I don't trust my
> > judgement this late into the night ;)
> > 
> Chad, would you have a few minutes when you're feeling fresh about the
> explicit vs implicit cleanup topic?

waffle_make_current(dpy, NULL, NULL) releases no memory allocated
by waffle itself, If any memory gets released, the backend call
(glXMakeCurrent, eglMakeCurrent) does the releasing.

Usually, eglMakeCurrent(dpy, NULL, NULL) does not release the currently
bound EGLContext. It only releases the currently bound EGLContext if the
context was queued for deletion by a previous call to
eglDestroyContext() or eglTerminate(dpy). 

I expect glXMakeCurrent behaves the same, but I'm not really sure.

So you're right. An EGLContext never gets truly released until you
unbind it with eglMakeCurrent(dpy, NULL, NULL, NULL). In theory,
according the EGL spec, it doesn't really matter if you unbind it before
or after eglDestroyContext, though. EGL will destroy it all the same.
However, to be safe against drivers with buggy resource tracking (ahem,
like Mesa), it's probably a good idea to unbind the context before
trying to destroy it.

Thanks for finding the bug [and reminding me :)]. I'll commit the
patches soon.


More information about the waffle mailing list