java native code_原生代码(native code)

原生代码是指不进行垃圾收集的代码,内存管理需要手动进行,而托管代码则由系统自动管理内存,包括垃圾收集。Java的JIT编译器在运行时将托管代码编译为原生代码,使得托管代码具备跨平台潜力。虽然.NET应用目前在平台移植上不及Java干净利落,但原理相似,通过安装Mono运行时可以在Linux或Mac上运行.NET应用。
摘要由CSDN通过智能技术生成

原生代码(native code)

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.

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(这就是Java的JIT编译器) 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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值