是否有任何 AppDomain/“动态编译代码”?限制?
我计划编写一个游戏,用户必须编写自己的 C# 代码才能玩它。 由于我不能信任用户提交的代码,我想为每个用户创建一个 AppDomain。 每个用户可以编写多个类,因此我需要动态编译和实例化每个类。其中一些类将有多个实例。
我不想限制用户数量,但假设有几百个用户注册。 这意味着我需要几百个 AppDomain,并且我正在编译/实例化更多的用户代码类。
在达到前面提到的用户数量之前,我会更早地遇到任何限制吗? (CPU/内存)
I'm planning to write a game, where the user has to write his own C# code to play it.
Since I can't trust the user submitted code I want to create an AppDomain for each user.
Each user can write several classes so I need to dynamically compile and instantiate each class. Where some of those classes will have multiple instances.
I don't want to restrict the user count, but lets say a few hundred users are registered.
Meaning I'd need a few hundred AppDomains and I'm compiling/instantiating a lot more usercode classes.
Is there any limitation I'll hit much earlier before I reach the user count mentioned earlier? (CPU/Memory)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以创建的 AppDomain 数量受到可用内存量的限制。因此,内存越多,您可以创建的 AppDomain 就越多。 CLR 没有施加任何限制。
如果您想找出您愿意在其上运行应用程序的特定操作系统/硬件所拥有的 AppDomain 数量,您可以编写一个简单的应用程序,以恒定的速率吐出 AppDomain,并查看在崩溃之前您可以走多远。虽然不是精确值,但它可以为您提供一个很好的近似值。
The number of AppDomains that you can create is limited by the amount of available memory. So the more memory the more AppDomains you can create. There is no limit imposed by the CLR.
And if you wanted to find out the number of AppDomains that the particular OS/hardware you are willing to run your application on has, you could write a simple application which spits AppDomains at a constant rate and see how far you can go before crashing. While not exact value it could give you a good approximation.