What is the difference between manageable and unmanageable code?
Purushottam Rathore
Managed code:Programming code is nothing but the Program is running under control of the CLR that is called managed code in .net.Example:MSIL code.UnManaged code:Programming code is nothing but the Program is not running under control of the CLR that is called Unmanaged code in .net.
Code which targets the .NET framework CLR is manageable meaning CLR can provide its services like type safety, memory management, exceptional handling etc to this type of code. Managed code is always compiled into MSIL. When a .NET application is run this compiled MSIL is compiled to native code using JIT (Just In Time compiler). This JIT generates the native code as per the hardware specification on the system. Since all this process happens under the control of a managed environment CLR, CLR provides all its rich functionality. Managed code provides platform independence since the code is converted to MSIL and then converted to native code depending on the system architecture.
The code that does not target CLR is unmanageable. It cannot run under CLR. This code directly runs under OS control. Applications written in traditional applications like C++, VB, C generate unmanaged code. Unmanaged code is always compiled directly to the native code which is architecture specific. This code cannot be executed on other platforms that are different than the one on which the code was compiled. All the features provided by CLR are unavailable and are to be taken care by the code. Hence this causes memory leaks in traditional applications.