linear-time weak-map gc

Oliver Hunt oliver at
Sun Mar 20 19:02:38 PDT 2011

On Mar 20, 2011, at 6:53 PM, David Herman wrote:

>> typically this is seen as a quality of implementation issue. Note the we (and most other language specs.) don't say much (or anything) about GC in general.  In one sense we don't need to say anything else about WeakMaps because it would be a lower quality implementation to retain objects in one that are provably not accessible. However, because of the long history of such poor implementations we need to say say just enough to make it clear what we expect.
>> It is something I'm sure I can draft when the time comes, but it isn't the most pressing matter.
> Sure. I shouldn't have caused a diversion about what goes in the spec. I have a reasonably clear picture of how to do it anyway.
> I am still curious how people write tests to evaluate the quality of weak references. Obviously you can expose lower-level, non-standard API's that provide metrics, but I wonder if there's any way to write standard code that tests weakly held data. I'm guessing there isn't. Again, this isn't pressing.

You can't test weakmap behaviour in any real way,  at least not without exposing really specific details of gc implementation.  To do so you'd have to require fairly explicit GC algorithms, and details about what an implementation is allowed to do in terms of lowering and what not, and when GC may occur.

I'm honestly not sure you can even test that a "weak map" is weak at all.


> Dave
> _______________________________________________
> es-discuss mailing list
> es-discuss at

More information about the es-discuss mailing list