Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between native and managed code?

Tags:

native

managed

For example, when looking at the GlowCode profiler website it says:

"GlowCode 6.2 and x64 profile native, managed, and mixed C++, C#, .NET code"

What do they mean?

like image 544
Joel Avatar asked May 13 '09 02:05

Joel


People also ask

What is difference between managed and unmanaged code?

Managed Code is converted to IL, Intermiddiate Language also termed as CIL of MSIL. Unmanaged Code is converted to native language code. Programmer has no low level access using Managed Code. Programmer can write low level access code using unmanaged code.

What do you mean by managed code?

To put it very simply, managed code is just that: code whose execution is managed by a runtime. In this case, the runtime in question is called the Common Language Runtime or CLR, regardless of the implementation (for example, Mono, . NET Framework, or . NET Core/.

What is the meaning of native code?

Native code is computer programming (code) that is compiled to run with a particular processor (such as an Intel x86-class processor) and its set of instructions. If the same program is run on a computer with a different processor, software can be provided so that the computer emulates the original processor.

What is managed code and unmanaged code with example?

It gets the managed code and compiles it into machine code. After that, the code is executed. The runtime here i.e. CLR provides automatic memory management, type safety, etc. C/C++ code, called "unmanaged code” do not have that privilege.


1 Answers

Native code is the code whose memory is not "managed", as in, memory isn't freed for you (C++' delete and C's free, for instance), no reference counting, no garbage collection. Managed code, you guessed it, is the code whose memory is free and allocated for you, garbage collection and other goodies.

Mixed code is when you have managed code that calls onto an unmanaged layer. Normally, when you have a pure unmanaged C++ DLL and you call it from .NET using P/invoke.

like image 68
Anzurio Avatar answered Sep 28 '22 03:09

Anzurio