开发者

What is managed and unmanaged code? [duplicate]

开发者 https://www.devze.com 2023-02-16 16:48 出处:网络
This question already has answers here: What is managed or unmanaged code in programming? 开发者_如何学Go
This question already has answers here: What is managed or unmanaged code in programming? 开发者_如何学Go (13 answers) Closed 4 years ago.

I found that some say managed code and unmanaged code. What is the difference? Is it only for .Net?


You can read this Wikipedia article, Managed code. Basically managed code is a Microsoft term, but the concept is not new. Consider the following definition:

An application program that is executed within a runtime engine installed in the same machine. The application cannot run without it. The runtime environment provides the general library of software routines that the program uses and typically performs memory management. It may also provide just-in-time (JIT) conversion from source code to executable code or from an intermediate language to executable code. Java, Visual Basic and .NET's Common Language Runtime (CLR) are examples of runtime engines.

Now contrast that to this definition of unmanaged code:

An executable program that runs by itself. Launched from the operating system, the program calls upon and uses the software routines in the operating system, but does not require another software system to be used. Assembly language programs that have been assembled into machine language and C/C++ programs compiled into machine language for a particular platform are examples of unmanaged code.


Managed code is where the runtime library manages your memory allocation, deallocations and garbage collections and you dont have to worry about memory much.

Unmanaged code allows pointers and direct memory access, And you should take care not to cause garbage or memory violation (segmentation faults)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号