Hacker News new | past | comments | ask | show | jobs | submit login

Copy them. I can think of no good reason that one would ever legitimately want or need to keep references to a page that is no longer loaded. It's like returning a pointer to a local variable from a C function; you should expect it to be invalid once it's scope is gone! Copying is likely to use less total memory anyway, because it will rarely result in having to allocate new compartments for the plugins, but it will allow an entire compartment for a page to be collected, that is otherwise kept around for the sake comparatively small objects.

This actually seems to me to have a lot of implications for the design of garbage collectors generally. In theory, correct garbage collectors are never supposed to collect objects that may still be used, which in practice usually means "that are reachable". But, we've already got such a thing as "weak references" to fudge that a little. This seems like kind of the opposite idea- having a sort of "superstrong" owner reference such that once it goes away, you know that the object will never be used again (or shouldn't be, anyway, with future uses constituting bugs), and can be collected despite what other references might exist.

It also seems like one of those obvious-after-the-fact genius ideas to have garbage collection running independently per compartment. Do Web Workers, e.g., get their own separate garbage collection, too? Any kind of shared-nothing concurrency model ought to be able to do the same thing to improve GC pauses; are there language implementations (I'm thinking probably Erlang here) that actually do that?




Each web worker gets its own compartment, and thus can be garbage collected individually.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: