CLR is a part of .NET Framework which manages the execution of several supported .NET languages, allowing them to share Common Object-Oriented Classes. CLR is somewhat comparable to Java Virtual Machine. Microsoft refers to its Common Language Runtime as “Managed Execution Environment“.
CLR held responsible for these important activities:
- Garbage Collection: CLR automatically manages memory, thus eliminating memory leaks. When objects are not referred, GC (Garbage Collector) automatically releases those memory thus providing efficient memory management.
- CAS (Code Access Security): CAS grants rights to program depending on the security configuration of the machine. For instance, if the program has rights to edit or create a new file but not to delete a file. CAS ensures that the code runs under the environment of machines security configuration.
- CV (Code Verification): This ensures proper code execution and type safety while the code runs. It prevents the source code to perform illegal operation such as accessing invalid memory locations etc.
- IL to Native code Translation/Optimization: CLR uses JIT and compiles the IL code to machine code and then executes. CLR also determines depending on platform what is optimized way of running the IL code.