C # WCF - Client / Server - System.OutOfMemory Exception

Problem.

  • C # WCF client / server application using Net TCP bindings (Publisher / Subscriber pattern).
  • Client side continues to fail with OutOfMemoryException.
  • When I start the task manager along with the client, I can see that the column of memory usage increases until the application crashes.
  • The intention is that multiple client instances run on separate machines.

Scenario

  • I have a client / server application.
  • Publisher / Subscriber Design Template.
  • On the server side, there are 6 dictionaries that make up the cache, each of which contains a user object as a value.
  • Each set of dictionary values ​​is updated every 5 seconds as part of a while loop.
  • At the end of a 5-second cycle, 6 dictionaries are added to the datacontract object, each as a different data item.
  • The data contract object is then sent over the wire to the client, where there are 6 more dictionaries.
  • Then I look at each dictionary of contract data and add or update the contents of its equivalent on the client side, depending on whether the values ​​exist or not.

Summary

  • 6 dictionaries on the server side.
  • 6 serializable dictionaries in a data contract.
  • 6 binding dictionaries on the client side.
  • WCF using Net TCP Binding to transfer data over a wire.

Specification

  • C # .Net 3.5
  • The client side uses one DevExpress form and 9 gridviews and DX tab controls.
  • , " ". - , , , , ( , , ).
  • (. ).

    NetTcpBinding netTcpBinding = new NetTcpBinding(SecurityMode.None);
    
    EndpointAddress endpointAddress = new EndpointAddress(EndpoindAddress);
    InstanceContext context = new InstanceContext(callbackinstance);
    
    netTcpBinding.MaxConnections = 5;
    netTcpBinding.MaxBufferSize = 2147483647;
    netTcpBinding.MaxBufferPoolSize = 2147483647;
    netTcpBinding.MaxReceivedMessageSize = 2147483647;
    netTcpBinding.ReceiveTimeout = TimeSpan.MaxValue;
    netTcpBinding.CloseTimeout = TimeSpan.MaxValue;
    netTcpBinding.TransferMode = TransferMode.Buffered;
    netTcpBinding.ListenBacklog = 5;
    
    DuplexChannelFactory<ISubscription> channelFactory =
       new DuplexChannelFactory<ISubscription>(
              new InstanceContext(this), 
              netTcpBinding,
              endpointAddress);
    
    proxy = channelFactory.CreateChannel();
    

  • ?
  • , , ?
  • ?
  • .
+3
3

• ?

Erm, , , , , , .

• , ?

.

• ?

• .

Windbg, , , , , ... , ,

+1

, ServiceChannelFactory WCF ?

0

MaxBufferPoolSize 2 (netTcpBinding.MaxBufferPoolSize = 2147483647;) , .

WCF , OutOfMemoryException.

.

0

Source: https://habr.com/ru/post/1773591/


All Articles