Talk:WeakPointers

From Gnash Project Wiki

Jump to: navigation, search

1

"we can presume that the function exists for the lifetime of all of its properties."

Actually, we can't. Here is an example:

test = function() {};
// assert (test.prototype.constructor == test)
var tmp = test.prototype;
delete test;
tmp.constructor = null; // drop last reference to function

Now the function doesn't exist anymore, but it's properties do.

2

"The advantage, however, of a weak reference for the initial constructor is that it will work correctly with a reference counting mechanism rather than requiring all the graph traversal-and-marking of a garbage collection algorithm."

The graph traversal-and-marking woudl still be needed as we can't rely on the constructor still being stored by a weak pointer (see override). The only advantage I see by mixing GC and RC is early release of resources (deregistration from the GC list).