6

Is CLR loaded and initialized everytime, when a new managed application is loaded and there is a managed application already present?

e.g. If on my machine, application "TestApp" is running and after that I start another application "DemoApp". In this case, wiill CLR be loaded again for DemoApp? Or it will use the same one which is loaded by TestApp?

TAdhav
  • 661
  • 10
  • 19

2 Answers2

8

Yes, and assemblies are JIT compiled, heaps are allocated and so forth. The Windows image loader will help a bit but in general the CLR overhead is per process.

Brian Rasmussen
  • 114,645
  • 34
  • 221
  • 317
  • Thanks.I want to know more about this.Can you suggest some resources? – TAdhav Jul 14 '10 at 12:04
  • For books please see http://stackoverflow.com/questions/477748/what-are-the-best-c-net-books/477751#477751 - Richter's book has lots of low level details about the CLR. For info on the Windows image loader check http://technet.microsoft.com/en-us/sysinternals/bb963901.aspx – Brian Rasmussen Jul 14 '10 at 13:33
  • @BrianRasmussen the SO link is broken – deostroll Feb 09 '16 at 14:36
  • @deostroll the question has been closed and deleted. CLR via C# is the book I would recommend to anyone looking to get a better understanding of .NET internals. – Brian Rasmussen Feb 09 '16 at 16:32
4

CLR is not fully loaded every time. The article linked below mentions a "hot startup" scenario, when the CLR is ready. You may have noticed this yourself when you start a .NET app for the very first time after system startup.

In the warm startup scenario (for instance, you have already run a managed application once), it is likely that most of the pages for the main common language runtime (CLR) components are already loaded in memory from where the OS can reuse them, saving expensive disk access time. This is why a managed application is much faster to start up the second time you run it. These soft faults dominate warm startup.

from http://msdn.microsoft.com/en-us/magazine/cc163655.aspx

BartoszKP
  • 34,786
  • 15
  • 102
  • 130
Marek
  • 10,307
  • 8
  • 70
  • 106