On 11 July 2012 15:35, Michael Schwartz <[email protected]> wrote: > GC finalization actually works for SilkJS. In the HTTP server, there are > two nested loops. The outer loop waits for connections, the inner loop > handles keep-alive requests. At the end of the inner loop (e.g. when the > connection is about to be closed), I force a GC (or at least try to). >
Hm, I don't quite follow. If you actually have a specific point where you know that you want to dispose a resource, why is it impossible to dispose it directly at that point? Or if there are many of them, you could maintain a set/map of them. In any case, before you conclude that finalization is the answer to your problems, let me +1 Sven's recommendation on reading Boehm's paper on the subject. Finalization is pretty much an anti-pattern. There are some rare, low-level use cases, but usually it creates more problems than it solves. That's why we only provide it in the C++ API. Also, I should mention that forcing a GC manually is highly discouraged. That causes a full (major, non-incremental) collection, which generally is a very costly operation that can cause significant pause time, and basically defeats most of the goodness built into a modern GC. /Andreas -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
