Reputation: 44776
I have two ASP.NET websites that reference the same class llibrary. Currently we publish the site with two copies of the class library. Does this waste memory? Does the OS know the two copies of the file are the same and so can share memory for the code sections of the DLL? If I copied it into the GAC or another shared location such that it was only one physical file, would it map less total memory?
Upvotes: 1
Views: 706
Reputation: 941227
This question starts off with the wrong premise, an ASP.NET DLL doesn't contain any code. Just data, IL and the assembly manifest. The jitter generates machine code from the IL, that code goes into the loader heap for the AppDomain. Private bytes of the process and not shared.
Getting one copy of the machine code that's generated from the IL is possible, you have to run Ngen.exe. It precompiles the IL and generates a native DLL, a .ni.dll that's stored in a GAC subdirectory. That code can be shared with only one copy of it in RAM.
Upvotes: 3
Reputation: 190897
A process and an app domain has to have it loaded into memory for it to function properly. App Domains and processes are sandboxed.
Upvotes: 0