每次加载 .NET 应用程序时都会加载 .NET 运行时吗?

发布于 2024-10-27 18:58:51 字数 374 浏览 3 评论 0原文

可能的重复:
CLR 是否每次都加载并初始化,何时加载新的托管应用程序?

当您启动某些 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

留蓝 2024-11-03 18:58:51

是的,.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.

情愿 2024-11-03 18:58:51
  1. 是的,.NET 运行时必须加载到每个新进程中,因为每个新进程都需要线程、堆、新的应用程序域等。

  2. 是的,除非它已经由 < code>ngen,在这种情况下它已经是 JIT 编译的。

  3. 是的,它明显减慢了启动速度。只需在启动后运行 Windows 窗体程序,您就会在硬盘上看到典型的大约 10-20 秒的延迟。不过,一旦事情开始,性能是可以接受的,尽管托管代码和非托管代码之间的转换有时可能会成为严重的瓶颈,具体取决于代码进行平台调用的次数。

  1. 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.

  2. Yes, unless it's already compiled by ngen, in which case it's already JIT'd.

  3. 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文