So somebody (ok it was me) didn't realize you need to close WCF proxies after using them.
How bad is this? What kind of problems 开发者_JAVA百科can it cause.
Is there just a delay in closing resources because of garbage collection - or should I really worry about things like premature app pool recycling?
I actually have far more ASMX than WCF proxies with this issue - so the same question goes for ASMX also.
Obviously now that I know this I'm going to gradually fix it, but would appreciate input on how bad this really is?
A WCF service has a default timeout. If you do not close it, the service will wait until there is a timeout.
WCF also has a max concurrent calls, that has a default of 10.
Therefore, if you do not close your connections you can only have 10 calls per min. (assuming default settings)
Here is someone with a similar problem:
http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/d58ee1c6-032b-40f3-b734-6628f3991bb2/
You can safely to reuse a WCF connection, just taking additional care to check if it's in a faulted state.
As a general guide when you are looking to gradually fix this, don't wrap your proxy's with a using statement, I've seen a lot of people do this, I was doing it until I read an article by IDesign that doing this might cause the Dispose to throw an exception and mask a real exception, explicitly close your proxy in try/catch, if close causes an exception, use Abort for resource clean up.
EDIT: As noted by the comment below this applies to WCF Proxies.
精彩评论