Explain Common Language Runtime in brief.
Common Language Runtime
- The common language runtime is the foundation of the .NET Framework.
- CLR is the basic and Virtual Machine component of the .NET Framework. It is the run-time environment in the .NET Framework that runs the codes and helps in making the development process easier by providing various services such as remoting, thread management, type-safety, memory management, robustness, etc.
- Basically, it is responsible for managing the execution of .NET programs regardless of any .NET programming language
The functionality of the CLR include:
- Management of code at execution time. Code that targets the runtime is known as Managed code, while code that does into target the runtime is known as Unmanaged code.
- Memory management
- Thread management.
- Enforcing strict type safety and other forms of code accuracy that promote security and robustness.
The language interoperability, and .NET Class Framework, are not possible without all the languages sharing the same data types. What this means is that an "int" should mean the same in VB. VC++, C#, and all other .NET compliant languages. The same idea follows for all the other data types. This is achieved through the introduction of the Common Type System (CTS).
A common type system (CTS) is an important part of the runtimes support for cross-language integration.
The common type system performs the following functions:
• Establishes a framework that enables cross-language integration, type safety, and high-performance code execution.
• Provides an object-oriented model that supports the complete implementation of many
programming languages.
IL compiler: It converts the Microsoft Intermediate Language(MSIL) or Common Intermediate Language(CIL) into the machine code.
Security component: In the CLR ensure that that assembly (the program being executed has permission to execute certain functions.)
Garbage collection
- Automatic memory management is made possible by Garbage Collection in .NET Framework. When a class object is created at runtime, a certain memory space is allocated to it in the heap memory.
- However, after all the actions related to the object are completed in the program, the memory space allocated to it is a waste as it cannot be used.
- In this case, garbage collection is very useful as it automatically releases the memory space after it is no longer required.
- Garbage collection will always work on Managed Heap and internally it has an Engine which is known as the Optimization Engine.
- Garbage Collection occurs if at least one of multiple conditions is satisfied. These conditions are given as follows:
- If the system has low physical memory, then garbage collection is necessary.
- If the memory allocated to various objects in the heap memory exceeds a pre-set threshold, then garbage collection occurs.
Comments
Post a Comment