How bad is it if I don't close WCF/ASMX proxies?

993 views Asked by At

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 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?

3

There are 3 answers

2
Shiraz Bhaiji On BEST ANSWER

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/

1
Rubens Farias On

You can safely to reuse a WCF connection, just taking additional care to check if it's in a faulted state.

2
Ta01 On

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.