开发者

Are there any AppDomain/"Dynamically compiled Code" limits?

开发者 https://www.devze.com 2023-03-25 10:18 出处:网络
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.

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 reac开发者_如何学编程h the user count mentioned earlier? (CPU/Memory)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消