Skip to content

Instantly share code, notes, and snippets.

@kumpera
Created March 23, 2012 14:45
Show Gist options
  • Save kumpera/2171321 to your computer and use it in GitHub Desktop.
Save kumpera/2171321 to your computer and use it in GitHub Desktop.
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.
@kumpera
Copy link
Author

kumpera commented Mar 23, 2012

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