[webgl-dev-list] when to call gl.deleteBuffer

577 views
Skip to first unread message

Jayesh Salvi

unread,
May 6, 2010, 1:44:24 AM5/6/10
to webgl-d...@googlegroups.com
Hi,

I have been playing around with WebGL after learning from the lessons at
learningwebgl.com (great resource, thanks Giles)

My dev machine is Fedora 11 with NVidia graphics card. I test using Firefox
3.7. What I have observed recently that after several hours of testing
my webgl code in firefox, the memory occupied by Xorg process increases
significantly. This led me to think about what kind of memory leak can
a webgl program cause.

I am not certain if the Xorg memory hog is caused by my Webgl programs,
but nonetheless I realized that my programs never call deleteBuffer on
the VBO objects I allocate using gl.bufferData. I couldn't find them in
learningwebgl tutorials as well (at least first 4 of them).

After realizing that, I considered what would be the right place to
delete these buffers. Should I be handling some callback that gets
triggered when tab/browser is closed? Or should the application logic
have hooks to track the life cycle of these buffers and delete them?

Any thought!

Thanks,
Jayesh

Giles Thomas

unread,
May 6, 2010, 7:11:16 AM5/6/10
to webgl-d...@googlegroups.com
On 6 May 2010 06:44, Jayesh Salvi <jayes...@gmail.com> wrote:
I am not certain if the Xorg memory hog is caused by my Webgl programs,
but nonetheless I realized that my programs never call deleteBuffer on
the VBO objects I allocate using gl.bufferData. I couldn't find them in
learningwebgl tutorials as well (at least first 4 of them).

Yup, my tutorials don't call deleteBuffer -- I'd been kind of assuming that the browser does it all for us when the page drops out of use.  This part of the spec <https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/WebGL-spec.html#3> seems to suggest that that should be the case, but (a) I may be misinterpreting it or (b) the browser might be buggy...


Cheers,

Giles
--
Giles Thomas
gi...@giles.net
http://www.gilesthomas.com/
http://learningwebgl.com/

Jayesh Salvi

unread,
May 7, 2010, 12:55:36 AM5/7/10
to webgl-d...@googlegroups.com
On Thu, May 06, 2010 at 12:11:16PM +0100, Giles Thomas wrote:
> On 6 May 2010 06:44, Jayesh Salvi <jayes...@gmail.com> wrote:
>
> I am not certain if the Xorg memory hog is caused by my Webgl programs,
> but nonetheless I realized that my programs never call deleteBuffer on
> the VBO objects I allocate using gl.bufferData. I couldn't find them in
> learningwebgl tutorials as well (at least first 4 of them).
>
> Yup, my tutorials don't call deleteBuffer -- I'd been kind of assuming
> that the browser does it all for us when the page drops out of use. This
> part of the spec
> <https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/WebGL-spec.html#3>
> seems to suggest that that should be the case, but (a) I may be
> misinterpreting it or (b) the browser might be buggy...

Thanks for the pointer.

This portion seems relevant...
"... When none of these conditions exist the user agent can, at any point,
delete the object using the equivalent of a delete call (e.g.,
deleteTexture). If authors wish to control when the underlying resource
is released then the delete call can be made explicitly."

IIUC the browser CAN delete the resources, but is not required to.
Fortunately the application itself can release these resources. We don't
know at this point if browser is doing the cleaning up. I will post if I
find something from my experiments with deleteBuffer in this regard.
Reply all
Reply to author
Forward
0 new messages