Click here to Skip to main content
16,013,918 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionHow to create a project on VS 2005 with .net 1.0 Pin
mercenary0125-Jul-07 23:25
mercenary0125-Jul-07 23:25 
AnswerRe: How to create a project on VS 2005 with .net 1.0 Pin
Mike Dimmick26-Jul-07 1:05
Mike Dimmick26-Jul-07 1:05 
AnswerRe: How to create a project on VS 2005 with .net 1.0 Pin
Pete O'Hanlon26-Jul-07 3:16
mvePete O'Hanlon26-Jul-07 3:16 
AnswerRe: How to create a project on VS 2005 with .net 1.0 Pin
Paul Conrad26-Jul-07 6:49
professionalPaul Conrad26-Jul-07 6:49 
AnswerRe: How to create a project on VS 2005 with .net 1.0 Pin
originSH26-Jul-07 22:51
originSH26-Jul-07 22:51 
QuestionRegarding CLR Execution in .NET Pin
Shyam K Pananghat25-Jul-07 20:47
Shyam K Pananghat25-Jul-07 20:47 
AnswerRe: Regarding CLR Execution in .NET Pin
Brady Kelly25-Jul-07 22:17
Brady Kelly25-Jul-07 22:17 
AnswerRe: Regarding CLR Execution in .NET Pin
Mike Dimmick26-Jul-07 2:02
Mike Dimmick26-Jul-07 2:02 
An unlimited number, or one, depending on what you're talking about.

There can be multiple versions of the .NET Framework CLR installed on a computer. There is however only one copy of mscoree.dll (per processor architecture), which is installed in the Windows System32 folder (on a 64-bit system, the 32-bit x86 version is in SysWOW64). This is really a stub responsible for loading the correct version of the real runtime (either mscorwks.dll or, for server GC on .NET 1.x, mscorsvr.dll).

Each process can only have one version of the CLR loaded (right now, this is 1.0.3705, 1.1.4322, or 2.0.50727). The first version requested is the only one ever loaded in that process. Unless otherwise guided by an application config file, .NET DLLs loaded via COM Interop will cause the latest version of the CLR installed on the system to be loaded into that process. 64-bit processes can only load v2.0 of the CLR because .NET 1.x doesn't support 64-bit.

Now we get into how Windows loads code and (initialised) data from program binaries (EXEs and DLLs). It actually loads them as shared (memory-mapped files) - the code and data are initially only in physical memory once. It also loads them on-demand - only when actually referenced, so loading a 5MB DLL doesn't immediately consume 5MB of physical memory. Writeable data pages are marked copy-on-write - they start out sharing the same data, but as soon as the process tries to write to the page, the OS makes a copy of it.

Read-only and unchanged copy-on-write pages can be re-read from the original file, so when trying to free up physical memory, Windows can simply discard the page, rather than having to write it out to the page file. The page is said to be backed by the original file. Pages that have been written to, and dynamically-allocated pages, are backed by the page file.

DLLs (and EXEs) have a base address. This is the virtual memory address, in the process's address space, that it would like to load at. Being the first thing to be loaded, the EXE always loads at its base address, but DLLs might have to be moved - relocated - elsewhere if there's something else already at that address (whether another DLL or some other allocation). Some native processor instructions only work with absolute addresses, which are written into the program code and data. When relocating a DLL, the OS has to change these addresses, so it copies the original page to a new page (backed by the page file) and modifies that.

So ideally, there's only one copy of read-only code and data from any EXE or DLL in physical memory at any one time, but there might be more if a DLL had to be relocated.

That's how it works for EXEs and DLLs containing native code. For managed, .NET code, Windows still loads the EXEs and DLLs as above, but the CLR must compile the IL code contained in the file into native code that the processor can actually execute. It does this by allocating memory in the process's address space which is unique to that process. Each process has its own copy of JIT-compiled code.

This would normally result in a lot of duplicated pages, hence physical memory overhead, so the Framework has the ability to pre-JIT compile whole assemblies and store them as native code on the disk, using the ngen program. It then loads these as regular native code DLLs, allowing Windows to do its normal sharing of these DLLs' pages between processes, as well as saving time since the JIT compiler step is not required. Large parts of the Framework are pre-JITted in this way. You can see the list (of 32-bit native assemblies generated by .NET 2.0) by going to Windows\Assembly\NativeImages_v2.0.50727_32 in a command prompt and getting a directory listing.

When it has loaded a native image, or JITted the code, the Framework still needs the original assembly for a few things (like Reflection and JITting other methods which refer to the assembly), but in general the original pages containing IL are not referenced that often, so Windows will eventually discard them.

Stability. What an interesting concept. -- Chris Maunder

GeneralRe: Regarding CLR Execution in .NET Pin
Luc Pattyn26-Jul-07 7:13
sitebuilderLuc Pattyn26-Jul-07 7:13 
GeneralRe: Regarding CLR Execution in .NET Pin
Shyam K Pananghat26-Jul-07 20:57
Shyam K Pananghat26-Jul-07 20:57 
Questionhow to create setup file for a sql server 2000 database project in vb.net Pin
bonny02022725-Jul-07 6:56
bonny02022725-Jul-07 6:56 
AnswerRe: how to create setup file for a sql server 2000 database project in vb.net Pin
Paul Conrad25-Jul-07 11:51
professionalPaul Conrad25-Jul-07 11:51 
QuestionForm with no titlebar Pin
kaleem tarar25-Jul-07 6:39
kaleem tarar25-Jul-07 6:39 
AnswerRe: Form with no titlebar Pin
Luc Pattyn25-Jul-07 8:22
sitebuilderLuc Pattyn25-Jul-07 8:22 
GeneralRe: Form with no titlebar Pin
Paul Conrad25-Jul-07 9:02
professionalPaul Conrad25-Jul-07 9:02 
GeneralRe: Form with no titlebar Pin
kaleem tarar25-Jul-07 10:50
kaleem tarar25-Jul-07 10:50 
GeneralRe: Form with no titlebar Pin
Paul Conrad25-Jul-07 11:01
professionalPaul Conrad25-Jul-07 11:01 
GeneralRe: Form with no titlebar Pin
Luc Pattyn25-Jul-07 12:01
sitebuilderLuc Pattyn25-Jul-07 12:01 
QuestionDatagrid image help Pin
boyindie25-Jul-07 6:33
boyindie25-Jul-07 6:33 
QuestionHow to do .Net performance measures? Pin
ffgtrg1616g261225-Jul-07 2:59
ffgtrg1616g261225-Jul-07 2:59 
AnswerRe: How to do .Net performance measures? Pin
Paul Conrad25-Jul-07 8:57
professionalPaul Conrad25-Jul-07 8:57 
GeneralRe: How to do .Net performance measures? Pin
ffgtrg1616g261225-Jul-07 22:48
ffgtrg1616g261225-Jul-07 22:48 
GeneralRe: How to do .Net performance measures? Pin
Paul Conrad26-Jul-07 10:11
professionalPaul Conrad26-Jul-07 10:11 
Question.Net 2.0, Classic ASP, and IIS 5.x Pin
#realJSOP25-Jul-07 1:43
professional#realJSOP25-Jul-07 1:43 
AnswerRe: .Net 2.0, Classic ASP, and IIS 5.x Pin
kubben25-Jul-07 2:06
kubben25-Jul-07 2:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.