[Webkit-unassigned] [Bug 18205] DOMNode objects are garbage collected although there are strong references

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Dec 5 03:00:47 PST 2008


https://bugs.webkit.org/show_bug.cgi?id=18205





------- Comment #22 from kai at granus.net  2008-12-05 03:00 PDT -------
By coincidence, I found the following in Apples "Garbage Collection Programming
Guide, Inapplicable Patterns", which I think applies perfectly to this problem:

Resource wrapper objects

A common pattern is to associate an object with an external resource—for
example, a file descriptor—that needs "management" or other state that the
object coordinates, often across several threads. The typical implementation is
to use a non-retaining CFDictionary coupled with a global lock at the lookup
and deallocation stages. This pattern does not work when you use garbage
collection because there is a timing window during finalization where the
object is no longer reachable from a root, yet is still in the dictionary and
can be resurrected.

The solution is to use an NSMapTable object. A map table can hold keys, values,
or both weakly, and when the objects are discovered unreachable the table is
immediately cleared of such entries before any finalization is performed. This
prevents resurrection of the object being finalized. For resources created and
destroyed within the application, such as file descriptors, this is an adequate
solution.


-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list