Open
Description
E.g.
[NoInterfaceObject]
interface Disposable {
void dispose();
};
Spec wording:
Creating classes registered on the global scope is the responsibility user agent. To allow authors to release resources used by these classes, the user agent must call the dispose() method on the class before destroying.
The only use-case for this is shared cache-objects on the global scope, and allowing code to clean up after themselves. Is it worth putting this in v1?
E.g.
var sharedCache = null;
var sharedCacheCount = 0;
registerAClass('foo', class Foo {
constructor() {
sharedCacheCount++;
if (!sharedCache) buildExpensiveCache();
},
dispose() {
sharedCacheCount--;
if (!sharedCacheCount) sharedCache = null; // Frees memory.
}
});