managed and unmanaged code in c#

     在看Unity plugin的时候,看到managed和unmanaged code,根据我所看的内容上下文,基本猜出来时啥意思。不过当时也就不求甚解那么过了。昨天看.net dll的一些内容的时候,重新看到了这个概念,于是google了一把。在一个论坛里面找到了一个比较全面科学的解释。

      "Unmanaged code" is a new name for an old concept. Unmanaged code stands for native machine code. Software is typically written in some high-level language such as Pascal, C or C++. These languages are translated into machine code (aka unmanaged code) by the compiler and its companion tools (assembler, linker, librarian, etc). The generated code runs natively on the host processor; that is, the processor directly executes the code generated by the compiler. This approach typically results in fastest code execution, but diagnosing and recovery from errors might be easier in managed code.

          Managed code is a new name, but the concept also is pretty old. Today, "managed code" typically stands for the system used by Microsoft .NET, but .NET is just one example of a managed code system. The .NET system takes source code in any of the supported languages (which include C, C++, C#, Pascal, and many others), and translates it into code designed for a virtual machine. The real processor cannot execute this code natively, but it can execute a program which then in turn executes the virtual machine's codes. The program that executes the virtual machine code is known as the virtual machine. While potentially slower than native code execution, the virtual machine can manage code (!) better than real machines. For example, the virtual machine can supervise memory allocation, automatically handle disposal of unused memory, and provide many other services that a native (unmanaged) application typically must explicitly provide. If the virtual machine does its job correctly, all applications using this virtual machine are likely to benefit.

 

         概念都是很老的,只不过两个新名词,类似pure java和jni。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值