[Mono-dev] Embedded mono: first on disk dynamic assembly stays locked, while others do not.

BaSS bassraf at gmail.com
Mon Aug 25 18:45:00 EDT 2008

Robert, awesome that it actually exposed a bug, I'm too new to mono to be sure that its not me, so thank you for actually reproducing it and posting the bug report.

Loading all the created script assemblies into the root domain would cause a huge memory consumption over time since I cannot unload the unused (because the scripts changed) assemblies. Am I correctly assuming this?

For now, I'll use my workaround by creating appdomains from the unmanaged side and loading the generated assemblies from disk, I've spend 5 days trying to figure out what I was doing wrong, so I better use this working solution or all goes to waste ;)

I'll keep an eye on the bug (and should setup a local build system for mono so I can actually use the fix from SVN...).

(it made me wonder how others currently embed mono as a scripting engine though, don't they use appdomains?)

Thank you for your help.

> -----Original Message-----
> From: mono-devel-list-bounces at lists.ximian.com [mailto:mono-devel-list-
> bounces at lists.ximian.com] On Behalf Of Robert Jordan
> Sent: Tuesday, August 26, 2008 00:22
> To: mono-devel-list at lists.ximian.com
> Subject: Re: [Mono-dev] Embedded mono: first on disk dynamic assembly
> stays locked, while others do not.
> Hi,
> BaSS wrote:
> >>> I'm using the mono embedding API and I'm using a construction like
> >> this:
> >>> 1) Setup Mono (2.0 beta or 1.9.1)
> >>> 2) Load main Assembly
> >>> 3) Create the script compiler object from the main assembly
> >>> 4) Invoke the managed scriptcompiler with a script(string) and have
> >> the assembly written to disk using a semi-random name
> >>> 5) from the unmanaged side, load the assembly from disk by its name
> >> mono_domain_assembly_open() into a new domain (mono_domain_create)
> >>> 6) do something with the assembly (run a method)
> >>> 7) use mono_domain_free() on the newly created secondary domain
> (from
> >> step 5)
> >>> 8) goto step 4 for the other scripts
> >> Why are you performing 5-8 from unmanaged code? This can be done
> much
> >> easier and less error-prone in managed code.
> >>
> >
> > Well, I'm having a weird problem when running code within the main
> assembly when calling it from the unmanaged side. When I call the same
> code using a test app in sharpdevelop, it works.
> > The managed code that fails when executed from the API is
> "AppDomain.CreateDomain("sandbox");" I get a stackoverflow in the
> mono.dll and everything comes to a halt. (all the other code works,
> just the createdomain fails..)
> OK, I was able reproduce this:
> https://bugzilla.novell.com/show_bug.cgi?id=420197
> I'd suggest you to load the generated assembly into the main appdomain
> until the bug is fixed.
> Robert
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list

More information about the Mono-devel-list mailing list