.NET Framework has CLR, Common Language Runtime which execute the code written in .NET languages. CLR manages the memory needs, security concern, code optimization, platform specific conversion etc. In case of Unmanaged code, no CLR is present, and code is directly executed by Operating system.
Following are some of the important differences between Managed and Unmanaged code.
|Sr. No.||Key||Managed Code||Unmanaged code|
|1||Executed By||Executed by CLR, Common Language Runtime, also named as Managed Runtime Environment.||Executed by Operating System directly on the underlying hardware.|
|2||Security||CLR handles security concerns and provides inbuilt security to code written in .NET.||No inbuilt security present. It is developer's responsibility to write safe and secure code.|
|3||Memory Overflow||Memory buffer overflow never happens, as CLR handles memory allocation and deallocation automatically.||Memory buffer overflow can occur and can hamper the program execution badly.|
|4||Runtime Services||CLR provides automatic garbage collection, exception handling to managed code.||No automatic garbage collection and other services are provided to unmanaged code.|
|5||Output||Managed Code is converted to IL, Intermiddiate Language also termed as CIL of MSIL.||Unmanaged Code is converted to native language code.|
|6||Low Level Access||Programmer has no low level access using Managed Code.||Programmer can write low level access code using unmanaged code.|