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

Review allocations #28

Open
yanchith opened this issue Jul 22, 2018 · 0 comments
Open

Review allocations #28

yanchith opened this issue Jul 22, 2018 · 0 comments

Comments

@yanchith
Copy link
Owner

yanchith commented Jul 22, 2018

We would like to support applications that try to avoid memory pressure, therefore we should not make unneeded allocations and buffer copies all over the place.

There are probably two classes of allocations happening right now:

  • const foo = bar || {}
  • buffer conversions, e.g. new Uint8Array([1, 2, 3])

Spawning new empty objects theoretically could be fine, as long as the particular vm has a generational gc, these objects should be very cheap to create and destroy (needs verifying). In any case, we can live without some js conveniences if it provides better experience overall.

Buffer conversions are more tricky. WebGL always requires data in a typed array format. Currently we try to not do needless conversions, but there are a few [] to typed array conversions which do copy data. We should probably remove buffer copying from those that are expected to be called often or in the rendering loop, e.g. VertexBuffer.store(). It also may make sense to create a separate higher-level API and make the current API strictly low-overhead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant