Open GoogleCodeExporter opened 9 years ago
Since Python already has a cycle detector, it'd be nice if we could leverage
this.
One way to do it might be:
Whenever Python's cyclic GC starts to run, make it call our callback (if this
is even
possible--if it's not possible, we'll have to manually call this function and
invoke
Python GC ourselves). When our callback is called, do the following:
1. Make a list of what JS runtimes are inactive.
2. Trace through each runtime, creating a table of how connected their
Python-exposed JS objects are to each other.
3. Temporarily increase the reference counts of each Python-exposed JS object to
reflect the other Python-exposed JS objects it's connected to. Let these
Python-exposed JS objects have access to the list of objects they're connected
to, so
that their tp_traverse callback can properly direct Python's cyclic GC to these
objects.
4. Allow Python's cyclic GC to proceed.
5. If a Python-exposed JS object's tp_clear callback is called, then it should
decrease its reference counts to all objects it refers to.
6. When Python's cyclic GC is done, "undo" any temporary incrementing done in #3
that has not yet been undone.
Original comment by var...@gmail.com
on 5 Sep 2009 at 5:12
Useful notes from XPCOM's cycle collector:
https://developer.mozilla.org/en/Interfacing_with_the_XPCOM_cycle_collector
http://mxr.mozilla.org/mozilla-central/source/js/src/xpconnect/src/nsXPConnect.cpp#414
http://mxr.mozilla.org/mozilla-central/source/xpcom/base/nsCycleCollector.cpp#40
Original comment by var...@gmail.com
on 6 Sep 2009 at 12:02
Original issue reported on code.google.com by
var...@gmail.com
on 5 Sep 2009 at 4:57