每次加载 .NET 应用程序时都会加载 .NET 运行时吗?
当您启动某些 .NET 应用程序时,操作系统是否也必须每次都加载 .NET 运行时,或者它是否已经在运行?
应用程序必须先进行 JIT 编译,然后才能由运行时每次执行,对吗?
这不是会减慢事情的进展吗?这是如何运作的?
Possible Duplicate:
Is CLR loaded and initialized everytime,when a new managed application is loaded ?
When you startup some .NET app, does the OS have to load the .NET runtime each time too or is that already running?
The app has to be JIT'ed before it can be executed each time by the runtime right?
Doesn't that slow things down? How does this work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,.NET 运行时是按进程
Re JIT;它是针对每个方法的,因此不需要全部进行 JIT 编译;而且速度非常快。您可以使用 NGEN(或单声道上的 AOT)来避免这种轻微的延迟。但 JIT 延迟很少是一个大问题。
Yes, the .NET runtime is per-process
Re JIT; it is per-method, so it doesn't all need to be JITted; and it is very fast. You can use NGEN (or AOT on mono) to avoid this slight delay. But JIT delay is rarely a huge problem.
是的,.NET 运行时必须加载到每个新进程中,因为每个新进程都需要线程、堆、新的应用程序域等。
是的,除非它已经由 < code>ngen,在这种情况下它已经是 JIT 编译的。
是的,它明显减慢了启动速度。只需在启动后运行 Windows 窗体程序,您就会在硬盘上看到典型的大约 10-20 秒的延迟。不过,一旦事情开始,性能是可以接受的,尽管托管代码和非托管代码之间的转换有时可能会成为严重的瓶颈,具体取决于代码进行平台调用的次数。
Yes, the .NET runtime has to be loaded into every new process, because every new process needs threads, a heap, new app domain(s), etc.
Yes, unless it's already compiled by
ngen
, in which case it's already JIT'd.Yes, it slows down startup quite noticeably. Just run a Windows Forms program after boot and you'll see a typical ~10-20 second delay on a hard disk. Once things get going, though, the performance is acceptable, although the transitions between managed and unmanaged code can sometimes be strong bottlenecks, depending on how heavily your code makes platform invoke calls.