[Mono-devel-list] Assembly.LoadFrom leak

Kornél Pál kornelpal at hotmail.com
Mon Jun 6 12:58:45 EDT 2005

> From: Marek Safar
> I don't like idea to create AppDomain for every assembly load. Once I
> don't need this assembly I set it to null.
> It should be enough.

I have little experience in the Mono runtime internals so I can't help more,
but assemblies are not unloaded either on .NET Framework or Mono after you
set their referece to null. They are unloaded only when all of the
AppDomains that loaded them is unloaded. This means if you have loaded an
assembly into multiple AppDomains you have to unload all of these AppDomains
to unload the assembly.

The main cause of this is that types in assemblies have static members that
are initialized when the type is first accessed and this static member
should not be collected while the AppDomain is loaded.

>> You are right, this is a leak but this leak is caused by you.:)
> Not sure, I am running same test under Microsoft Runtime and it works
> fine.

It's possible that Mono is not so efficient regarding this problem as .NET
Framework but the leak itself is caused by you by loading a lot of
assemblies without unloading them.

But note that I have the opinion as well that Mono should cope with more
than 500 assemblies.


More information about the Mono-devel-list mailing list