1

I have created a wcf service hosted in an exe process, and instantiated the client through class library which makes calls to the service. The class library is for a com addin to excel 2007 and the reason for the wcf service is so we don't use up excel in-proc memory when retrieving large amounts of data.

I've created the wcf service by implementing ClientBase with WSHttpBinding. I'm currently testing with a bare bone project and the only function is to return a message from the wcf service.

My question is regarding the memory usage in creating the wcf client and why it doesn't get released once it has been disposed. I've used address space monitor to monitor the memory usage and creating the binding and client uses around 70mb of committed memory.

Any information on wcf memory usage or GC for com dlls would be useful

Thanks

2 Answers2

0

Heres a writeup:

http://www.danrigsby.com/blog/index.php/2008/02/26/dont-wrap-wcf-service-hosts-or-clients-in-a-using-statement/

Also Below is a thread similiar to yours that was posted awhile ago. It was answered by Igor Zevaka. Hopefully it could add more knowledge.

this.Dispose() doesn't release memory used by Form after closing it.

Community
  • 1
  • 1
LOZ
  • 1,169
  • 2
  • 16
  • 43
0

THats the way garbage collection in .net works. In all sorts of places it gives advantages, however in some it seems to be a hinderance. You may find - and i am stretchign things a bit - that when you dispose of 1 form and create a new instance it reuses that memory space. Although i doubt it.

Anyway ... garbage collection in .net is kinda interesting imo.

It will get cleaned up eventually ... just in an indeterminate amount of time.

I believe there is a command to force the garbage collection

Best Practice for Forcing Garbage Collection in C#

Of course its a bit like fight club - dont talk abou tit and if you do find it, you probably will wish you hadnt

GC.Collect();

iirc

Also dispose has an overload that takes a bool. When you call true on that it also goes through all its parts forcing them. There are several dispose patterns that are easily googleable. Juval Lowry goes into them in great depth in his components book.

Community
  • 1
  • 1
John Nicholas
  • 4,778
  • 4
  • 31
  • 50