Concerns about weak refs and weak maps.

felix felix8a at gmail.com
Fri Oct 29 16:01:23 PDT 2010


On 10/29/10 15:18, Jim Deville wrote:
> C# 4.0 has WeakMap's too, and one of the goals was to work around the cyclical reference issue:
>
> http://blogs.msdn.com/b/clrteam/archive/2009/05/18/the-conditional-weak-table-enabling-dynamic-object-properties.aspx

mono implements ConditionalWeakTable with Ephemeron tables registered 
with the GC.  The registration does nothing with boehm-gc, but there is 
special handling for Ephemerons in the experimental sgen-gc, and it 
looks to me like it's similar to what's described on the ECMAScript wiki 
for WeakMap: repeatedly scan Ephemeron key,value entries for values that 
are newly reachable, until no more newly-reachable values are found.

http://github.com/mono/mono/blob/09ae7f243df64f6928ffcd89eb44ac1f688c689e/mono/metadata/sgen-gc.c

it's instrumented to count how many times it repeats the Ephemeron scan, 
so it probably wouldn't be too hard to get practical data on how 
expensive it is in real usage.


More information about the es-discuss mailing list