Created
March 23, 2012 14:45
-
-
Save kumpera/2171321 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Foo : Java.Lang.Object { Java.Lang.Object obj; } | |
| var foo = new Foo(); | |
| var text = new EditText (); | |
| var foo2 = new Foo (); | |
| //The 3 objects are reachable from the stack | |
| foo.obj = text; | |
| text.Click += () -> foo2.Something (); | |
| foo2.obj = foo; | |
| //The bridge reachability graph is: | |
| foo -> text --- foo can reach text | |
| text -> foo2 | |
| foo2 -> foo | |
| foo = text = button; | |
| GC.Collect (); | |
| //All objects are not collectible on the C# side | |
| We'll have the following SCC passed to the bridge callback: [foo, text, foo2] | |
| This order is accidental and we must not rely on it. | |
| Now it will try to the following: | |
| add_reference (foo, text) //ok | |
| add_reference (text, foo2) //fail | |
| add_reference (foo2, foo) //ok | |
| So the induced java reachability graph is: | |
| foo -> text | |
| foo2 -> foo | |
| Now say the only reachable object in java land is button, both foo and foo2 | |
| will be collected and we're broken. |
Not really, say the SCC is [foo foo2 clickHandler text]
We'll induce the following graph on java:
foo -> foo2
foo2 -> clickHandler
clickHandler -> text
We have this direct graph:
text -> clickHandler
So, given text is the only naturally (without the induced vertices) reachable java object, both foo and foo2 would be collected.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The bridge reachability graph is incorrect; we need to introduce more temporaries.
Instead of:
it's really:
Now I need to guess that the bridge reachability graph would really be:
I have no idea how the C# delegate mechanism interplays with the bridge code; does it just "skip" all non-
Java.Lang.Objecttypes, thus leavingclickHandler -> foo2?Again, I'm guessing that the SCC would be
[foo, text, clickHandler, foo2].It would then try the following:
HOWEVER (please correct me if I'm wrong), because of the
text.SetOnClickHandler()call,textDOES have a reference to clickHandler, via theView.mOnClickListenerfield.I THINK that the induced Java reachability graph would thus be:
There would also be a direct object graph:
Which I believe is correct, and we're fine.