emscripten-core/emscripten

WebIDL binder: Use WeakRefs in cache

Open

#9854 aperta il 18 nov 2019

Vedi su GitHub
 (7 commenti) (2 reazioni) (0 assegnatari)C++ (3519 fork)batch import
good first bughelp wanted

Metriche repository

Star
 (27.361 star)
Metriche merge PR
 (Merge medio 19g 10h) (147 PR mergiate in 30 g)

Descrizione

The cache maps C pointers (integers) to JS object wrappers. It currently keeps objects alive forever. This is normally ok as the objects should be manually destroy()ed, however, we do allow wrapping a class as a parent class, and then it ends up in multiple caches, see https://github.com/kripken/ammo.js/issues/284

Using WeakRefs where available could avoid this. However, until they are present everywhere, perhaps we could analyze the inheritance graph and clean up parent caches too, but that may be tricky especially with multiple/virtual/etc. inheritance.

Guida contributor