Juan Ignacio Dopazo dopazo.juan at gmail.com
Wed Sep 14 18:04:48 PDT 2011

On Wednesday, September 14, 2011, David Bruant <david.bruant at labri.fr>
> Also, I would like to talk a little bit about terminology. WeakMaps have
> their name inspired by the idea of "weak" references which have
> particular garbage-collection properties. From the developer
> perspective, this seems to be some sort of implementation detail they
> should not be aware of.
> As far as I know, current functions/constructors have their name
> inspired by the contract they fulfill rather than implementation
> considerations. The difference between current WeakMaps and Maps is
> their contract. In the latter, keys can be enumerated, in the former
> not. I think that this is the difference that should inspire different
> names rather than the implementation optimisation that is induced by
> this contract difference.

In the last few days I had to write a piece of code that would strongly
benefit from WeakMaps. I needed to store information about DOM nodes and
retrieve it later, and these nodes aren't in my control so they can be
detached at any time by someone else. If the references I kept were weak,
I'd be sure that I wouldn't be causing a memory leak. And that's important
in this case because the nodes are very likely Flash objects which can
easily mean 20-50mb in memory. So knowing that a reference is weak is
important information.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110914/c0fca346/attachment.html>

More information about the es-discuss mailing list