tags:

views:

1118

answers:

3

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?

+9  A: 

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.

Anzurio
+3  A: 

Native code is compiled to work directly with the OS. Managed code however, is precompiled (bytecode in Java-speak) but is then processed by the Just In Time Compiler to native code at runtime. Managed code has the interesting side effect of having the potential of running on different operating systems, because the machine code is not created until the VM actually uses it. This way, you are able to run .NET apps on Windows and also run them on Linux or Mac that have the Mono runtime installed. The portability is not as clean currently as Java is (because of Microsoft's naturally closed architecture), but the concept remains.

If you are running an unmanaged app, the code has been compiled to run for the designated OS/Hardware. Any portability to another OS/instruction set is lost and must be recompiled to execute.

Wayne Hartman
+2  A: 

Native code is written in the "native" machine language of the computer that it is running on and is executed directly by the processor.

Managed code is written in a special language that requires another program to run (i.e. manage) it. This other program is often called an interpreter as it interprets the special language.

C and C++ programs are native.

Java and C# (and all .NET languages for that matter) are managed.

Managed C++ is a special form of C++ that runs in the .NET interpreter.

A mixed program is a program that uses code that is both native and managed.

onedozenbagels

related questions