views:

67

answers:

2

I have created WCF application which is running on Windows Service. It was installed using Windows Installer. I have followed procedure mentioned in following article for same.

http://msdn.microsoft.com/en-us/library/bb332338.aspx#msdnwcfhc_topic4

Most WCF properties are kept as default for net.tcp protocol, per call instance and so on.

Memory consumption of service keeps on increasing after every call and does not decrease. At the end it throws OutOfMemory consumption.

Application returns very heavy string based data. With memory-profiler I found memory is still allocated to string objects and increases during call.

As per my understanding string is managed objects should release data once out of scope.

Let me know if any other configuration/coding information is needed specifically.

A: 

There must be something keeping references to those strings in the code. Can you use your profiler to trace the references that are keeping the string objects alive?

Chris Smith
Using memory pro-filer I found many objects are still in memory and not getting released. Even string object is not released, though I think it might be related to http://msdn.microsoft.com/en-us/magazine/cc534993.aspx this. Am arriving at conclusion that I need to restart service if it reaches certain memory limit.
BigBoss
Can't you publish what kind of objects are not released? Are there any disposable objects that you are not disposing probably?
Kangkan
Kindly check newly added comment.
BigBoss
When a collection occurs, those objects (including the strings) will be unallocated UNLESS there is a specific traceable connection to a root object. Do a trace for one of these string objects that should be getting release to reveal the reference path that is keeping the object alive. See http://blogs.msdn.com/b/delay/archive/2009/03/11/where-s-your-leak-at-using-windbg-sos-and-gcroot-to-diagnose-a-net-memory-leak.aspx
Chris Smith
A: 

It would be very difficult to answer this question without some code to look at. You can always call GC.Collect(GC.MaxGeneration) to force garbage collection and see if this doesn't reduce your memory consumption. Ideally this would only be temporary code to track down what is going on in the application. If forcing garbage collection does not reduce memory consumption then references to the strings must be being retained, via static member variables or whatever: having no conception of what the code is, any theory would be a shot in the dark

Steve Ellinger
I did tried GC.Collect() and some other garbage collector methods but it ended up with no result. Apparently I found it is related to large objcts LOH http://msdn.microsoft.com/en-us/magazine/cc534993.aspx, which does not get disposed properly.
BigBoss
kindly check newly added comment.
BigBoss