elm-explorations / webgl

Functional rendering with WebGL in Elm
https://package.elm-lang.org/packages/elm-explorations/webgl/latest/
BSD 3-Clause "New" or "Revised" License
117 stars 17 forks source link

Use WeakMap to fix memory leaks #9

Closed w0rm closed 5 years ago

w0rm commented 5 years ago

Addresses memory leaks caused by many programmatically created textures and meshes: https://github.com/elm-community/webgl/issues/46

According to spec buffers and textures should be garbage collected together with JS objects:

Note that underlying GL object will be automatically marked for deletion when the JS object is destroyed, however this method allows authors to mark an object for deletion early.

It looks that browsers that support WebGL also support WeakMap, but just in case I added a test for WeakMap support.