Is there a limit in the maximum number of mutexes per process/thread in a Asp.net application?
Just in case the target operating systems are: Windows XP Pro, server 2003/2008 and Windows 7 in the near future.
Usually the website is deployed in an App Pool.
I'm going to go out on a limb here and venture the possibility that you're probably (not necessarily) doing something wrong.
Raymond Chen said it best but, if you're worried about the maximum number of mutexes, you're probably protecting your resources at too fine a granularity.
Certainly there will be a maximum number even if it's dictated by available memory rather than a constant. However, I can't see any valid situation in which you would need so many mutexes that you would hit a limit.
I'm not saying it's not possible since I have no idea what the architecture of your application is. But I would be very surprised if there wasn't a better way to do it.
Perhaps if you step back and tell us the "what I want" rather than the "how I did it", we could offer better advice.
The limit is essentially the same as the limit on the number of handles a process can have. It's quite a big number: 16,777,216. Of course, the real limit is much lower, and depends on how much non-paged pool you have available, which isn't that big.
If you're worried about the limit, there's something wrong with your program. Keep in mind that critical sections usually delay the creation of any kernel objects, which means you can have a large number of them if there are few contentions.