Under what circumstances will .NET processes and AppDomains share loaded assemblies in memory? Under what circumstances will .NET processes and AppDomains share loaded assemblies in memory? asp.net asp.net

Under what circumstances will .NET processes and AppDomains share loaded assemblies in memory?


One case in which assembly sharing occurs are assemblies compiled to native code with ngen.exe. Let me cite "CLR via C#" (Chapter 1)

The NGen.exe tool is interesting in two scenarios:

...

Reducing an application’s working set - if you believe that an assembly will be loaded into multiple processes simultaneously, running NGen.exe on that assembly can reduce the applications’ working set. The reason is because the NGen.exe tool compiles the IL to native code and saves the output in aseparate file. This file can be memory-mapped into multiple-processaddress spaces simultaneously, allowing the code to be shared; notevery process needs its own copy of the code.