There is a .NET WCF service running under an app pool in IIS 8 in Windows Server 2012. The memory usage of the app pool keeps increasing every time the service is called. (It drops slightly when the service is idle). The memory consumption is now at 1GB. The memory usage reduces only when the app pool gets recycled which is currently set at its default of 29 hrs. Is this type of memory consumption an expected behavior? I was under the impression that the memory would be released once the request is complete
-
Are you properly disposing of resources in your code? Could be causing memory leaks – mituw16 Jun 22 '17 at 16:49
-
Do you have any code you can show us? – Tim Hutchison Jun 22 '17 at 18:16
-
Take memory profiler and check if consumption is normal or not – Ed Pavlov Jun 23 '17 at 14:43
2 Answers
Whether this is expected or not is going to depend on a number of things, including what the service does, what the code looks like, what resources are used, what kind of service activation you configured and the binding and more.
The question is going to be to figure out if what you're really seeing a memory leak or not, but that will require a lot more information, including a careful analysis of the "CLR Memory" performance counters and OS counters such as "Process\Handle Count" and "Process\Private Bytes".
I'd suggest starting first with a through analysis of performance counters to determine if you're really seeing a leak or not, and then using tools such as PerfView and dump analysis to figure out what's going on.

- 13,683
- 3
- 38
- 30
Normlaly .NET garbage collector will release the memory after use provided you have written code perfectley fine.In your case your application is having memory leak as some part of the code or some library you are using is consuming the memory and not releaseit.A simple example can be
A static collection defined which loads some data from database . This will never be collected by GC as in our code we have defined it as static.Similarly there are other causes like a Session data ,MemoryCache, dynamic assemblies, and countless others.
For more information on how it can happen ,check Common Causes of Memory Leaks , what to do for memory leak ,causes of leak SO post.
In effect,first you have to investigate the cause of the memory leak and then fix the code or library which is leaking memory.