title: Out of memory when sending large data collections
body: <p>I have a product that works fine in most case but then I have one case where I get a lot of out of memory exceptions(on service).</p>
  
  <p>The service is a WCF service hosted as a Windows Service. The service is using netTCPBinding and Protobuf-net to communicate with the Winform clients. Service is set PerCall and uses SessionMode.Required. At the service I keep context objects for the clients to be able to keep track.</p>
  
  <p>The service do also use callbacks. </p>
  
  <p>Both service and client is built as 32 bit so this limits it to use 2 GB ram.</p>
  
  <p>The environment(1000 users) that generates the our of memory exceptions is a lot bigger then the other installations. A thought is that some of the messages is large and that when multiple users request this data at the same time the memory are entirely consumed.</p>
  
  <p>The binding looks like this :</p>
  
  <pre><code>&lt;binding name="netTcpRegular" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="infinite" sendTimeout="01:00:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="1000" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="200" maxReceivedMessageSize="2147483647"&gt;
            &lt;readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/&gt;
            &lt;reliableSession ordered="true" inactivityTimeout="infinite" enabled="false"/&gt;
            &lt;security mode="None"&gt;
              &lt;transport clientCredentialType="None"/&gt;
            &lt;/security&gt;
          &lt;/binding&gt;
        &lt;/netTcpBinding&gt;
  </code></pre>
  
  <p>Could the maxBufferSize be the problems?</p>
  
  <p>The Service Throttling is set like this : </p>
  
  <pre><code>&lt;serviceThrottling maxConcurrentCalls="2000" maxConcurrentSessions="2147483647" maxConcurrentInstances="2000"/&gt;
  </code></pre>
  
  <p>Its possible that also the maxConcurrentCalls is set to high? Maby we should go down to 64?</p>
  
  <p>Rebuild it as a 64 bit software is also a way, this should clear the 2 GB limit of ram.</p>