gpt4 book ai didi

.net - 如何在不指定域中立性的情况下将 .net native 镜像 (NGEN) 加载到多个应用程序域中?

转载 作者:行者123 更新时间:2023-12-04 06:39:03 25 4
gpt4 key购买 nike

NGEN + AppDomain 问题在这里。

我正在对一些应用程序进行更改,这些更改围绕使 native 图像正确加载以防止我们的 .net 应用程序中出现糟糕的 JIT 时间。有些部分很简单,但任何必须在 appdomains 中加载的程序集(我们的应用程序由于各种原因必须使用它)只会在第一次和后续加载时加​​载它们的 native 图像(在现在是一个新的 appdomain 中)图像被拒绝并发生 JIT。

我对域中立加载了如指掌,并且已经在一些有意义的程序集中使用了它,但是进行域中立加载取消了我们首先使用 appdomains 的主要原因之一——因为域中性图像永远无法卸载。

简而言之,我需要一种方法来加载 native 图像和卸载程序集。我曾希望只要在尝试再次加载 native 镜像之前卸载了 native 镜像的第一次使用,正常限制就不会适用,但这导致拒绝,就像尝试同时加载 native 镜像一样。

This MSDN article包含以下引用:

An alternative approach to falling back to JIT compilation is to load different copies of the native image into every AppDomain that loads the corresponding assembly as domain-specific. However, this approach would require every copy of the NGen image, except for the first, to be loaded at a different address from its preferred base address. Thus all of these copies of the NGen image would need their addresses fixed up.



这将非常适合我的需求,但那篇文章是我见过它提到的唯一地方,我不确定它将如何实现。

提前感谢您的任何见解,并感谢您的关注。

最佳答案

I had hoped that the normal restriction wouldn't apply as long as I unloaded the first usage of the native image before I tried to load it again, but this resulted in rejection just like if trying to load the native image concurrently.



这有效,但您必须等待 native 镜像实际卸载。当 AppDomain.Unload 返回时,appdomain 并未完全卸载。只有在下一次完整的 GC 之后,appdomain 才会完全卸载(连同 native 图像)。

This MSDN article contains the following quote:



Surupa 正在推测 CLR 中可能的替代实现,但目前尚未实现。

谢谢
拉克山费尔南多
CLR团队

关于.net - 如何在不指定域中立性的情况下将 .net native 镜像 (NGEN) 加载到多个应用程序域中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4503888/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com