Quick links: C-Tricks HR Interview Que. Code Snippets C Programs C++ Programs Java Programs PHP Examples

Home » .Net

What are the roles of CLR (Common Language Runtime) in .NET Framework?

Learn: What are the roles of Common Language Runtime (CLR) in .Net framework? Explain the roles in details.

CLR (Common Language Runtime) is basic component of .NET Framework. It provides an environment to run .NET applications on targeted machine. CLR provides environment for all .NET languages compilers for converting source code into a common language known as IL or MSIL or CIL.

CLR provides multiple services to execute processes, like memory management service and security services. CLR performs multiple tasks to manage the execution of .NET applications. Following responsibilities of CLR are given below:

  1. Automatic memory management
  2. Code access security
  3. Garbage collection
  4. JIT compilation

1) Automatic memory management

CLR calls various predefined functions of .NET framework to allocate and de-allocate memory of .NET objects. So that, developers need not to write code to explicitly allocate and de-allocate memory.

2) Code access security

CLR allows access to code to perform only those tasks for that it has permission. It also checks user’s permissions using authentication and configuration files of .NET applications.

3) Garbage collection

GC is used to prevent memory leaks or holes. Garbage collector of CLR automatically determines the best time to free the memory, which is allocated to an object for execution.

4) JIT compilation

JIT stands for Just In Time. It is also an important part of Common Language Runtime (CLR), JIT compiler converts MSIL code to targeted machine code for execution.