[Mono-list] Unload AppDomain containing GTK Window

Adrian Stern adrian.stern at screenfood.com
Mon Jul 2 13:44:55 UTC 2012


Hello

Since the Flashplugin is not very stable and on top of that leaks memory in long term use we try to run this critical part in a seperate AppDomain.
While creating and interacting with this window works fine, unloading the updomain causes the whole app to crash.

Since the unload works when i remove the Gtk.Window from the marshal object i can confirm this problem to be Gtk related (GTK Sharp)
Run on Ubuntu 11.4 and 12.4. This Bug seems to be known since 2004.

Running this sample every x seconds (loop) should just open a new window every x seconds while closing and destroying the other.

Any idey how i could accomplish this?

What i do:
#################################################
##### Class to run in other AppDomain and ist proxy class
#################################################

public class Fanta
{
  string s;

 // commenting this line out will cause the example to work!
  Gtk.Window w = new Gtk.Window(Gtk.WindowType.Toplevel);

  public Fanta(){ s = "blubb"; }

  public void echoS(){ Console.WriteLine( s );}
}

public class FantaProxy : MarshalByRefObject
{
  Fanta f = new Fanta();

  public void echoS(){
    f.GetType().InvokeMember("echoS", BindingFlags.InvokeMethod, null, f, null );
  }
}

#################################################
##### Code which causes the app to exit
#################################################

// d is a gobal AppDomain
// fp is FantaProxy  Type (also global)

d = AppDomain.CreateDomain( "FantaD");
string currentAssemblyPath = Assembly.GetExecutingAssembly().Location;
fp = d.CreateInstanceFromAndUnwrap( currentAssemblyPath, "AppDomainTest.FantaProxy" ) as FantaProxy;
fp.echoS();
AppDomain.Unload( d );
Diese E-Mail und ihre Anh?nge enthalten vertrauliche und/oder rechtlich gesch?tzte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrt?mlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail inklusive Anh?nge. Das unerlaubte Kopieren sowie die unbefugte Weitergabe der Inhalte dieser Mail ist nicht gestattet.
This e-mail and any attachments may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail including the attachments. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-list/attachments/20120702/845681ac/attachment.html>


More information about the Mono-list mailing list