Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaning up buffers #56

Open
simonharrisco opened this issue Jan 2, 2019 · 3 comments
Open

Cleaning up buffers #56

simonharrisco opened this issue Jan 2, 2019 · 3 comments
Labels
type/feat A new feature

Comments

@simonharrisco
Copy link
Contributor

In the book I'm reading, along with at this SO answer buffers are cleaned up by nulling them before deletion.

The book is quite unhelpful in just saying that this is 'best practice' without explaining why, but the SO answer also included it.

I cant find anywhere that this is done in pex-context

Is this because when loading lots of things it could cause some issues of emptying a say ARRAY_BUFFER that is being used elsewhere.

Would this cause memory leaks in pex nodes when switching between graphs?

@vorg
Copy link
Member

vorg commented Jan 3, 2019

Currently we only delete the buffers and they indeed stay bound the the attribute forever (or until next buffer is bound).

By cleaned up by nulling i think you mix two concept. You can clean texture/buffer binding gl.bindBuffer(gl.ARRAY_BUFFER, null). Then you delete the buffer gl.deleteBuffer(someBuffer).

As for attributes i've never heard about creating empty buffer and binding it to clear previous bindings. It does make sense but would love to know what are the implications of not doing that. Same with "set a buffer to 1 byte before deleting". Currently we only disable unused attributes.

@simonharrisco Anything in your WebGL 2 rendering book?

One good piece of advice is resizing canvas when you are done with webgl context. Added an issue for it #57

@vorg
Copy link
Member

vorg commented Jan 3, 2019

Another thing i've seen is people using WEBGL_lose_context.loseContext() to force resources release although it's not an official way.

@dmnsgn
Copy link
Member

dmnsgn commented Mar 20, 2019

WEBGL_lose_context.loseContext is hard to reason about because implementations varies. I'd keep it in user land.

@dmnsgn dmnsgn added type/feat A new feature and removed enhancement labels Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feat A new feature
Projects
None yet
Development

No branches or pull requests

3 participants