1

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)

Arokh
  • 614
  • 1
  • 10
  • 18

1 Answers1

1

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.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • Ok, sounds like doing that what I want to do is not a crazy idea. I was worried that this was something like creating something like a million threads when 10 would have done it. Thanks – Arokh Aug 03 '11 at 16:00
  • @Arkoh, no it is not a crazy idea when you want to ensure proper sandboxing of different code parts. – Darin Dimitrov Aug 03 '11 at 16:01