Open In App
Related Articles

Difference between Managed and Unmanaged code in .NET

Improve Article
Save Article
Like Article

Managed code is the code which is managed by the CLR(Common Language Runtime) in .NET Framework. Whereas the Unmanaged code is the code which is directly executed by the operating system. Below are some important differences between the Managed code and Unmanaged code: 

Managed Code

Unmanaged Code

It is executed by managed runtime environment or managed by the CLR. It is executed directly by the operating system.
It provides security to the application written in .NET Framework. It does not provide any security to the application.
Memory buffer overflow does not occur. Memory buffer overflow may occur.
It provide runtime services like Garbage Collection, exception handling, etc. It does not provide runtime services like Garbage Collection, exception handling, etc.
The source code is compiled in the intermediate language known as IL or MSIL or CIL. The source code directly compiles into native languages.
It does not provide low-level access to the programmer. It provide low-level access to the programmer.
Memory is managed by CLR’s Garbage Collector. Memory is managed by the programmer.
Performance is Slightly slower due to the overhead of memory management and JIT compilation. Performance is Faster due to direct access to system resources and compiled machine-specific code.
Debugging is easier due to the availability of CLR’s debugging tools. Debugging is harder due to lack of debugging tools.
Managed code requires installation of CLR on the target machine Unmanaged code Can be distributed as a standalone executable or DLL file.
Interoperates well with other .NET languages and libraries. Limited interoperability with .NET languages .
Runs on any platform that has CLR installed. Runs only on the specific platform for which it is .



Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 16 May, 2023
Like Article
Save Article
Similar Reads