WCF not freeing up unused buffer
I开发者_Go百科 have a wcf service and i am using below config values for the same.
maxItemsInObjectGraph="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
Everything works fine except that my service keeps occupaing the memory. I have narrowed down the problem and the reason it is occuping lots of memory is because it is not freeing up these unused buffer size. When i use defalt values for that, it works just right with no too much memory.
Is there a way i can make service claim the unused space?
I'm curious as to how you determined these settings are the cause of your issue, and what you are looking at to determine the memory usage, and over how much time and how many requests you let it run.
Do you get an OutOfMemory exception after a couple requests?
Note that 2147483647 bytes is 2GB, so it would take about 2 or 3 requests before you would run out of memory if these buffers were being fully allocated and not released.
Are you sure that the memory just isn't being GC'd because there is no reason to? If heap space is available, and under certain thresholds, it don't have much of a reason to spend time GC'ing things.
Edit:
You may also see different memory usage based on the size of these created buffers and objects. Some of this is outlined here. Basically .net treats objects over 85,000 bytes as 'large' and compacts them differently.
Again though, if you never get a memory exception or actually run out of memory, then you probably don't have an issue. "different" memory usage doesn't mean it is "wrong". You should load test your application and see if it actually runs out of memory, which would indicate a real memory leak. Otherwise, it might just build up memory until it approaches the max heap gen sizes then GC everything.
精彩评论