Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As you use 'GZipMessageEncodingBindingElement', I assume you are using the MS GZIP sample.</p> <p>Have a look at <code>DecompressBuffer()</code> in GZipMessageEncoderFactory.cs and you will understand what's going on in buffered mode.</p> <p>For the sake of example, let's say you have a message of uncompressed size 50M, compressed size 25M.</p> <p>DecompressBuffer will receive an 'ArraySegment buffer' param of (1) <strong>25M</strong> size. The method will then create a MemoryStream, uncompress the buffer into it, using (2) <strong>50M</strong>. Then it will do a MemoryStream.ToArray(), copying the memory stream buffer into a new (3) <strong>50M</strong> big byte array. Then it takes another byte array from the BufferManager of AT LEAST (4) <strong>50M+</strong>, in reality, it can be a lot more - in my case it was always 67M for a 50M array.</p> <p>At the end of DecompressBuffer, (1) will be returned to the BufferManager (which seems to never get cleared by WCF), (2) and (3) are subject to GC (which is async, and if you are faster than the GC, you might get OOM exceptions even though there would be enough mem if cleaned up). (4) will presumably be given back to the BufferManager in your BinaryMessageEncodingBindingElement.ReadMessage().</p> <p>To sum up, for your 50M message, your buffered scenario will temporarily take up <strong>25 + 50 + 50 + e.g. 65 = 190M</strong> memory, some of it subject to asynchronous GC, some of it managed by the BufferManager, which - worst case - means it keeps lots of unused arrays in memory that are neither usable in a subsequent request (e.g. too small) nor eligible for GC. Now imagine you have multiple concurrent requests, in that case BufferManager will create separate buffers for all concurrent requests, which will <strong>never</strong> be cleaned up, unless you manually call BufferManager.Clear(), and I don't know of a way to do that with the buffer managers used by WCF, see also this question: <a href="https://stackoverflow.com/questions/7252417">How can I prevent BufferManager / PooledBufferManager in my WCF client app from wasting memory?</a> ]</p> <p><strong>Update:</strong> After migrating to IIS7 Http Compression ( <a href="https://stackoverflow.com/questions/4631627/wcf-conditional-compression/7278500#7278500">wcf conditional compression</a>) <strong>memory consumption, cpu load and startup time dropped</strong> (don't have the numbers handy) and then migrating from buffered to streamed TransferMode ( <a href="https://stackoverflow.com/questions/7252417/how-can-i-prevent-buffermanager-pooledbuffermanager-in-my-wcf-client-app-from-w/7253103#7253103">How can I prevent BufferManager / PooledBufferManager in my WCF client app from wasting memory?</a>) <strong>memory consumption of my WCF client app has dropped from 630M (peak) / 470M (continuous) to 270M (both peak and continuous)</strong>!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload