Difference between native and managed code?

Joel picture Joel · May 13, 2009 · Viewed 67.1k times · Source

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?

Answer

Anzurio picture Anzurio · May 13, 2009

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.