What is the difference in managed and unmanaged code, memory and size?

Viewed 71354

After seeing and listening a lot regarding managed and unmanaged code, and knowing the only difference is that managed is about CLR and un-managed is outside of the CLR, it makes me really curious to know it in detail. What is it all about, managed and unmanaged code, memory and size?

How can code I write in C# be unmanaged while this is C# code and how does a memory of size becomes unmanaged. An example and a little insight would be helpful.

6 Answers

Unmanaged Code :-

1.The code, which is developed outside .NET, Framework is known as unmanaged code.

2.Applications that do not run under the control of the CLR are said to be unmanaged, and certain languages such as C++ can be used to write such applications, which, for example, access low - level functions of the operating system. Background compatibility with code of VB, ASP and COM are examples of unmanaged code.

3.Unmanaged code is executed with help of wrapper classes.

4.Wrapper classes are of two types: CCW (COM Callable Wrapper) and RCW (Runtime Callable Wrapper).

5.Wrapper is used to cover difference with the help of CCW and RCW. Managed Code The resource, which is with in your application domain is, managed code. The resources that are within domain are faster.

Managed Code 1.The code, which is developed in .NET framework, is known as managed code. This code is directly executed by CLR with help of managed code execution. Any language that is written in .NET Framework is managed code.

2.Managed code uses CLR which in turns looks after your applications by managing memory, handling security, allowing cross - language debugging, and so on.

Related