Inconsistent existence of

Describe the bug

Documentation states (here):

In general, it’s recommended to check the API or documentation of a class and watch for dispose(). If present, you should use it when cleaning things up.

However, the existence of dispose() across API is inconsistent. E.g. SpotLightHelper has dispose() but CameraHelper does not. Based on the above statement from the documentation, one might assume a CameraHelper does not need to be disposed, but such a conclusion would leak one material and one geometry that the CameraHelper creates internally (probably unknown by the user). To know this, you must look at the source code of CameraHelper to see how it works, which is doable but not optimal.

I propose that any object which creates materials/geometries/textures internally should have a dispose() method to dispose of those internally-created-resources (like SpotLightHelper already does … but others do not).

If this is of interest to the maintainers, I can volunteer to send in a PR. If not, I will not send in a PR. 🙂 Let me know. I have an SPA site so I’ve found many of these missing-dispose() objects and have runtime patches to fix them already in my app.

1 possible answer(s) on “Inconsistent existence of

  1. It vote for option 2. Adding an empty (abstract) dispose() in Light and implement it in all shadow casting light classes.